home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet internetowy / Rozne / HTTrack 3.40-2 / httrack-3.40-2.exe / {app} / src_win / WinHTTrack / Shell.cpp < prev    next >
C/C++ Source or Header  |  2005-11-19  |  110KB  |  3,043 lines

  1. // Shell.cpp : Defines the class behaviors for the application.
  2. //
  3.  
  4. // thread windows
  5. #include <process.h>
  6.  
  7. #include "stdafx.h"
  8. #include "Shell.h"
  9. #include "NewProj.h"
  10.  
  11. #include "htsbase.h"
  12.  
  13. // Ras
  14. #if USE_RAS 
  15. #include "RasLoad.h"
  16. #endif
  17.  
  18. #include <afxdisp.h>
  19. #include "ras.h"
  20. #include "mmsystem.h"
  21.  
  22. //#include "ShellDoc.h"
  23. //#include "ShellView.h"
  24.  
  25. #ifdef _DEBUG
  26. #define new DEBUG_NEW
  27. #undef THIS_FILE
  28. static char THIS_FILE[] = __FILE__;
  29. #endif
  30.  
  31. // PATCH-->
  32. // PATCH-->
  33. #include "about.h"
  34. #include "infoend.h"
  35.  
  36. // flag de termination
  37. int termine=0;
  38. int termine_requested=0;
  39. int shell_terminated=0;
  40. int soft_term_requested=0;
  41. FILE* fp_debug=NULL;
  42.  
  43. #include "stdafx.h"
  44. #include "Shell.h"
  45. #include "process.h"
  46. //#include "ShellDoc.h"
  47. //#include "ShellView.h"
  48. //#include "essai.h"
  49. //#include "get.h"
  50. //#include "parameter.h"
  51. extern "C" {
  52.   #include "HTTrackInterface.h"
  53.   #include "htssystem.h"
  54. }
  55. #include "Wid1.h"
  56. #include "trans.h"
  57. #include "InfoUrl.h"
  58. //#include "option.h"
  59. //#include "filter.h"
  60. //#include "wizard.h"
  61. //
  62. #include "maintab.h"
  63. //
  64. #include "MemRegister.h"
  65.  
  66. // LANG
  67. #include "newlang.h"
  68.  
  69.  
  70. // PATCH-->
  71. //#include "wizard2.h"
  72. //#include "WizLinks.h"
  73.  
  74. #include "inprogress.h"
  75.  
  76. #include "SYS\TIMEB.H"
  77.  
  78. // htswrap_add
  79. extern "C" {
  80.   #include "htswrap.h"
  81. };
  82.  
  83. // --- --- --- --- Options --- --- --- ---
  84.  
  85. #define MAX_LEN_INPROGRESS 32
  86.  
  87. // lancement en multithread du shell ET de gethostbyname
  88. #define SHELL_MULTITHREAD 1
  89. //#define HTS_XGMETHOD 2    // 1: AfxBeginThread 2: _beginthread
  90. // --- --- --- --- Options --- --- --- ---
  91. //int INREDRAW_LOCKED=0;      // refresh graphique en cours
  92. //int INFILLMEM_LOCKED=0;     // refresh mΘmoire en cours
  93. int HTTRACK_result=0;
  94. //
  95. CInfoUrl* _Cinprogress_inst=NULL;
  96.  
  97. extern HICON httrack_icon;
  98.  
  99. /* Main splitter frame */
  100. #include "DialogContainer.h"
  101. #include "splitter.h"
  102. extern CSplitterFrame* this_CSplitterFrame;
  103.  
  104. /* Main WizTab frame */
  105. #include "WizTab.h"
  106. extern CWizTab* this_CWizTab;
  107. /* Argh - pas de domodal dans des autres threads ?!?! */
  108. char WIZ_question[1000];
  109. char WIZ_reponse[1000];
  110.  
  111.  
  112. // Fonctionnement des THREADS:
  113. //
  114. // principal ---> robot & refresh data (thread 1)
  115. //           ---> refresh graphique    (thread 2)
  116. //           GO!> boucle gestion domodal() et boutons
  117. // arrΩt: principal demande l'arrΩt (termine_requested)
  118. //        thread1 active termine et que thread2 ait fini de refresher
  119. //        thread2 se termine
  120. //        thread1 retourne 0 α hts_loop
  121. //        le robot termine
  122. //        le thread1 active termine, termine le formulaire et se termine
  123. //        principal ayant quittΘ le formulaire affiche le message de fin
  124.  
  125.  
  126. // htslib.c
  127. extern "C" {
  128.   HTSEXT_API void qsec2str(char *st,TStamp t);
  129. }
  130.  
  131. // construction index gΘnΘral
  132. // void Build_TopIndex();
  133.  
  134. void compute_options() ;
  135. static void StripControls(char * chaine);
  136. void lance(void);
  137. int check_continue(char* pathlog);
  138. int inprogress_refresh();
  139. //int inprogress_refresh_scan();
  140. void Write_profile(CString path,int load_path);
  141. void Read_profile(CString path,int load_path);
  142.  
  143.  
  144. // dΘja fait mais bon
  145. #define HTS_WIN 1
  146.  
  147. extern "C" {
  148.   #include "htscore.h"
  149. }
  150.  
  151. CString _HTTRACK_VERSION = HTTRACK_VERSION;
  152.  
  153. CShellOptions* ShellOptions;
  154.  
  155.  
  156. // Fichier tempo
  157. FILE* tmpf=NULL;
  158. MemRegister tmpm;
  159.  
  160. CNewProj* dialog0=NULL;
  161. Wid1* dialog1=NULL;
  162. Ctrans* dialog2=NULL;
  163. //Coption dialog3;
  164. //Cfilter diafiltre;
  165. /*
  166. wizard diawiz;
  167. wizard2 diawiz2;
  168. WizLinks diawiz3;
  169. */
  170. //
  171. CMainTab* maintab=NULL;
  172. CShellApp* CShellApp_app=NULL;
  173.  
  174. #include "infoend.h"
  175. extern Cinfoend* this_Cinfoend;
  176.  
  177.  
  178. // PATCH-->
  179. Cinprogress* inprogress=NULL;
  180.  
  181. // nbre de slides
  182. t_StatsBuffer StatsBuffer[NStatsBuffer];
  183. void* StatsBufferback=NULL;
  184. int StatsBufferback_max=0;
  185. InpInfo SInfo;
  186.  
  187. #if USE_RAS
  188. // Chargement des librairies RAS
  189. CDynamicRAS* LibRas=NULL;
  190. int LibRasUse=0;
  191. //
  192. int connected=0;
  193. int disconnect=0;
  194. int shutdown_pc=0;
  195. HRASCONN conn = NULL;
  196. int has_started=0;
  197. char connected_err[1000]="";
  198. #endif
  199.  
  200. // pour message final
  201. extern char end_mirror_msg[8192];
  202. #include "winhttrack.h"
  203. extern CWinHTTrackApp* this_app;
  204.  
  205.  
  206. // PATCH-->
  207. // PATCH-->
  208. // FIN PATCH
  209.  
  210.  
  211. /////////////////////////////////////////////////////////////////////////////
  212. // CShellApp
  213.  
  214. /*
  215. BEGIN_MESSAGE_MAP(CShellApp, CWinApp)
  216. //{{AFX_MSG_MAP(CShellApp)
  217. ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
  218. // NOTE - the ClassWizard will add and remove mapping macros here.
  219. //    DO NOT EDIT what you see in these blocks of generated code!
  220. //}}AFX_MSG_MAP
  221. // Standard file based document commands
  222. ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
  223. ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
  224. // Standard print setup command
  225. ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup)
  226. ON_COMMAND(ID_HELP, CWinApp::OnHelp)
  227. END_MESSAGE_MAP()
  228. */
  229.  
  230. /////////////////////////////////////////////////////////////////////////////
  231. // CShellApp construction
  232.  
  233. CShellApp::CShellApp()
  234. {
  235.   // TODO: add construction code here,
  236.   // Place all significant initialization in InitInstance
  237. }
  238.  
  239. /////////////////////////////////////////////////////////////////////////////
  240. // The one and only CShellApp object
  241.  
  242. //CShellApp theApp;
  243.  
  244. /////////////////////////////////////////////////////////////////////////////
  245. // CShellApp initialization
  246.  
  247. static void __cdecl RunBackMirror( LPVOID pP ) {
  248.   CShellApp_app->init_lance();
  249. }
  250.  
  251. BOOL LaunchMirror() {
  252.   WHTT_LOCK();
  253.   hts_resetvar();
  254.   WHTT_UNLOCK();
  255.   (void)hts_newthread(RunBackMirror, 0, NULL);
  256.   return 0;
  257. }
  258.  
  259. #if 0
  260. BOOL CShellApp::InitInstance()
  261. {
  262.   CShellApp_app=this;
  263.   termine=termine_requested=shell_terminated=soft_term_requested=0;
  264.   
  265.   // Initialize OLE libraries
  266.   /*
  267.   if (!AfxOleInit())
  268.   {
  269.   AfxMessageBox(LANG(LANG_F1));
  270.   return FALSE;
  271.   }
  272.   AfxEnableControlContainer();
  273.   */
  274.   
  275.   // Fixer localisation dans la base de registre
  276.   //SetRegistryKey("WinHTTrack");
  277.   
  278.   // Standard initialization
  279.   // If you are not using these features and wish to reduce the size
  280.   //  of your final executable, you should remove from the following
  281.   //  the specific initialization routines you do not need.
  282.   /*
  283.   #ifdef _AFXDLL
  284.   Enable3dControls();            // Call this when using MFC in a shared DLL
  285.   #else
  286.   Enable3dControlsStatic();    // Call this when linking to MFC statically
  287.   #endif
  288.   */
  289.   
  290.   // Register the application's document templates.  Document templates
  291.   //  serve as the connection between documents, frame windows and views.
  292.   
  293.   // Change the registry key under which our settings are stored.
  294.   // You should modify this string to be something appropriate
  295.   // such as the name of your company or organization.
  296.   //SetRegistryKey(_T("Local AppWizard-Generated Applications"));
  297.   
  298.   //LoadStdProfileSettings();  // Load standard INI file options (including MRU)
  299.   
  300.   // Register the application's document templates.  Document templates
  301.   //  serve as the connection between documents, frame windows and views.
  302.   
  303.   // Parse command line for standard shell commands, DDE, file open
  304.   /*CCommandLineInfo cmdInfo;
  305.   ParseCommandLine(cmdInfo);
  306.   */
  307.   
  308.   _Cinprogress_inst=NULL;
  309.   
  310.   LibRasUse=0;
  311.   
  312.   /*
  313.   #if USE_RAS
  314.   LibRas=new CDynamicRAS();
  315.   if (LibRas->IsRASLoaded()) 
  316.   LibRasUse=1;
  317.   else
  318.   LibRasUse=0;
  319.   #endif
  320.   */
  321.   
  322.   maintab = new CMainTab("WinHTTrack Website Copier");
  323.   
  324.   // PATCH-->
  325.   // ΘxΘcution..
  326.   init_lance();
  327.   
  328.   delete maintab;
  329.   maintab=NULL;
  330.   
  331.   // PATCH-->
  332.   /*
  333.   // Dispatch commands specified on the command line
  334.   if (!ProcessShellCommand(cmdInfo))
  335.         return FALSE;
  336.     
  337.       // The one and only window has been initialized, so show and update it.
  338.       m_pMainWnd->ShowWindow(SW_SHOW);
  339.       m_pMainWnd->UpdateWindow();
  340.   */  
  341.   
  342.   
  343.   return TRUE;
  344. }
  345. #endif
  346.  
  347. // PATCH-->
  348. // routines diverses
  349.  
  350. char* _SN(LLint n) {
  351.   static char str[256];
  352.   str[0]='\0';
  353.   sprintf(str,LLintP,(LLint)n);        /* 64-bit */
  354.   return str;
  355. }
  356.  
  357. // t existe-t-il comme rΘpertoire?
  358. int dir_check(char* t) {
  359.   int dir;
  360.   FILE* fp=fopen(t,"rb");
  361.   dir=(errno==13);  // is directory
  362.   if (fp) fclose(fp);
  363.   return dir;
  364. }
  365.  
  366. void check_temp(char* t,char* s) {
  367.   if (strlen(s)==0)
  368.     if (dir_check(t))
  369.       strcpybuff(s,t);
  370. }
  371.  
  372.  
  373.  
  374. // PATCH-->
  375. // Routines gestion dials
  376. // PatchΘ pour 100% dials
  377.  
  378.  
  379. void CShellApp::init_lance() {
  380.   hts_init();
  381.   htswrap_add("check-link",httrackengine_check);
  382.   htswrap_add("check-mime",httrackengine_check_mime);
  383.   htswrap_add("init",httrackengine_init);
  384.   htswrap_add("free",httrackengine_uninit);
  385.   htswrap_add("start",httrackengine_start);
  386.   htswrap_add("end",httrackengine_end);
  387.   htswrap_add("preprocess-html",httrackengine_htmlpreprocess);
  388.   htswrap_add("postprocess-html",httrackengine_htmlpostprocess);
  389.   htswrap_add("check-html",httrackengine_htmlcheck);
  390.   htswrap_add("change-options",httrackengine_chopt);
  391.   htswrap_add("loop",httrackengine_loop);
  392.   htswrap_add("query",httrackengine_query);
  393.   htswrap_add("query2",httrackengine_query2);
  394.   htswrap_add("query3",httrackengine_query3);
  395.   htswrap_add("pause",httrackengine_pause);
  396.   htswrap_add("save-file",httrackengine_filesave);
  397.   htswrap_add("save-file2",httrackengine_filesave2);
  398.  
  399.   termine=termine_requested=shell_terminated=soft_term_requested=0;
  400.   lance();             // Lancer miroir!
  401.   if (fp_debug) {
  402.     fprintf(fp_debug,"Building top index\r\n");
  403.     fflush(fp_debug);
  404.   }
  405.   Build_TopIndex();
  406. }
  407.  
  408. /* sauver profile */
  409. /* ask: demande confirmation, si cela vaut le coup */
  410. int Save_current_profile(int ask) {
  411.   CString winprofile;
  412.   if (ask) {
  413.     if ((dialog0->GetName().IsEmpty()) && (dialog1->m_urls.IsEmpty()))
  414.       return IDNO;
  415.     int r;
  416.     char msg[256];
  417.     sprintf(msg,"%s?\r\n%s",LANG_SAVEPROJECT,dialog0->GetName());
  418.     if ((r=AfxMessageBox(msg,MB_YESNOCANCEL)) != IDYES)
  419.       return r;
  420.   }
  421.   //
  422.   CWaitCursor wait;
  423.   
  424.   // sauver whtt
  425.   {
  426.     CString st=dialog0->GetBasePath()+dialog0->GetName()+".whtt";
  427.     FILE* fp=fopen(st,"wb");
  428.     if (fp) fclose(fp);
  429.   }
  430.   
  431.   // sauver ini
  432.   winprofile=dialog0->GetPath();
  433.   if (winprofile.GetLength()>0)
  434.     if ((winprofile.Right(1)!="/") && (winprofile.Right(1)!="\\"))
  435.       winprofile+="\\";
  436.     winprofile+="hts-cache\\";
  437.     {
  438.       char tempo[HTS_URLMAXSIZE*2];
  439.       int i;
  440.       strcpybuff(tempo,winprofile);
  441.       for(i=0;i<(int)strlen(tempo);i++)
  442.         if (tempo[i]=='\\')
  443.           tempo[i]='/';              
  444.         structcheck(tempo);
  445.     }
  446.     
  447.     winprofile+="winprofile.ini";
  448.     Write_profile(winprofile,0);
  449.     
  450.     // marquer document comme "sauvΘ"
  451.     if (this_CSplitterFrame)
  452.       this_CSplitterFrame->SetSaved();
  453.     
  454.     return IDYES;
  455. }
  456.  
  457. // reprise possible?
  458. int check_continue(char* pathlog) {
  459.   char path_log[256];
  460.   strcpybuff(path_log,pathlog);
  461.   if (strlen(path_log)>0)
  462.     if ((path_log[strlen(path_log)-1]!='/') && (path_log[strlen(path_log)-1]!='\\'))
  463.       strcatbuff(path_log,"/");
  464.     if (
  465.       fexist(fconcat(path_log,"hts-cache/new.zip"))
  466.       ||
  467.       (fexist(fconcat(path_log,"hts-cache/new.dat"))) && (fexist(fconcat(path_log,"hts-cache/new.ndx")))
  468.       ) {  // il existe dΘja un cache prΘcΘdent.. renommer
  469.       //if (fexist(fconcat(path_log,"hts-cache/doit.log"))) {    // un cache est prΘsent
  470.       return 1;
  471.       //}
  472.     }
  473.     if (
  474.       fexist(fconcat(path_log,"hts-cache/old.zip"))
  475.       ||
  476.       (fexist(fconcat(path_log,"hts-cache/old.dat"))) && (fexist(fconcat(path_log,"hts-cache/old.ndx")))
  477.       ) {  // il existe dΘja un ancien cache prΘcΘdent.. renommer
  478.       return 1;
  479.     }
  480.     AfxMessageBox(LANG(LANG_F2 /*"There is no cache in the directory indicated\nWinHTTrack can not find any interrupted mirror!"*/),MB_OK+MB_ICONSTOP);
  481.     return 0;
  482. }
  483.  
  484.  
  485. void CShellApp::OptPannel() {
  486.   Write_profile("<mem>",0);       // enregistrer profile dans buffer local
  487.   if (maintab->DoModal()==IDCANCEL) {
  488.     Read_profile("<mem>",0);      // restaurer
  489.   }
  490. }
  491.  
  492.  
  493. #define ADD_MIME_IN_COPT(A) \
  494.   if(strlen(maintab->m_option11.m_ext##A)+strlen(maintab->m_option11.m_mime##A)) { \
  495.   ShellOptions->buff_MIME += "--assume "; \
  496.   ShellOptions->buff_MIME += maintab->m_option11.m_ext##A; \
  497.   ShellOptions->buff_MIME += "="; \
  498.   ShellOptions->buff_MIME += maintab->m_option11.m_mime##A; \
  499.   ShellOptions->buff_MIME += " "; \
  500.   } \
  501.   
  502. // parser maintab et calculer options
  503. void compute_options() { 
  504.   CWaitCursor wait;
  505.   
  506.   /* Effacer options */
  507.   if (ShellOptions != NULL) {
  508.     delete ShellOptions;
  509.     ShellOptions = NULL;
  510.   }
  511.   ShellOptions = new CShellOptions();
  512.   /* Effacer options */
  513.   
  514.   // Mode de miroir
  515.   switch(dialog1->m_todo) {
  516.   case CB_ERR: case 0:
  517.     ShellOptions->choixdeb = "w";
  518.     break;
  519.   case 1:
  520.     ShellOptions->choixdeb = "W";
  521.     break;
  522.   case 2:
  523.     ShellOptions->choixdeb = "g";
  524.     break;
  525.   case 3:
  526.     ShellOptions->choixdeb = "Y";
  527.     break;
  528.   case 4:
  529.     ShellOptions->choixdeb = "!";
  530.     break;
  531.   default:
  532.     if (dialog1->m_todo==dialog1->LAST_ACTION)
  533.       ShellOptions->choixdeb = "i";    // reprise
  534.     else
  535.       ShellOptions->choixdeb = "/";    // reprise cache prioritaire
  536.     break;
  537.   }
  538.   
  539.   // URLS
  540.   ShellOptions->url = dialog1->m_urls;
  541.   StripControls(ShellOptions->url.GetBuffer(0));
  542.   // --- formation du path
  543.   ShellOptions->path = "\"";
  544.   ShellOptions->path += dialog0->GetPath0();
  545.   ShellOptions->path += "\"";
  546.   //ShellOptions->path += ",";
  547.   //ShellOptions->path += "\"";
  548.   //ShellOptions->path += dialog0->GetPath0();
  549.   //ShellOptions->path += "\"";
  550.   
  551.   // filelist
  552.   {
  553.     CString st=dialog1->m_filelist;
  554.     st.TrimLeft();
  555.     st.TrimRight();
  556.     ShellOptions->filelist = st;
  557.   }
  558.   
  559.   // stocker Θtat et hh/mm/ss
  560.   ShellOptions->hh = dialog2->m_hh;
  561.   ShellOptions->mm = dialog2->m_mm;
  562.   ShellOptions->ss = dialog2->m_ss;
  563.   if (ShellOptions->hh.GetLength()) {    // heure
  564.     int x,y,z;
  565.     sscanf(ShellOptions->hh.GetBuffer(0),"%d",&x);
  566.     x=min(max(x,0),23);
  567.     ShellOptions->hh.Format("%d",x);
  568.     //
  569.     sscanf(ShellOptions->mm.GetBuffer(0),"%d",&y);
  570.     y=min(max(y,0),59);
  571.     ShellOptions->mm.Format("%d",y);
  572.     //
  573.     sscanf(ShellOptions->ss.GetBuffer(0),"%d",&z);
  574.     z=min(max(z,0),59);
  575.     ShellOptions->ss.Format("%d",z);
  576.     //
  577.     ShellOptions->waittime = "";
  578.     {
  579.       char str[32];
  580.       ShellOptions->waittime = "#u";
  581.       sprintf(str,"%d",x*3600+y*60+z);
  582.       ShellOptions->waittime += str;
  583.     }
  584.   }
  585.   ShellOptions->_RasString = dialog2->RasString;
  586.   ShellOptions->_dial=dialog2->dial;
  587.   
  588.   if (ShellOptions->choixdeb[0]=='/') {
  589.     ShellOptions->cache = "C1";      // cache prio
  590.   } else {
  591.     if(!maintab->m_option3.m_cache) 
  592.       ShellOptions->cache = "C0"; 
  593.     else 
  594.       ShellOptions->cache = "C2";     // cache non prio 
  595.     //ShellOptions->cache[0]='\0'; 
  596.   }
  597.   
  598.   // ne pas recharger fichiers dΘja pris mais effacΘs
  599.   if(maintab->m_option9.m_norecatch) ShellOptions->norecatch = "%n"; else ShellOptions->norecatch = "";
  600.   
  601.   // proxy
  602.   ShellOptions->proxy = maintab->m_option10.m_proxy;
  603.   ShellOptions->port = maintab->m_option10.m_port;
  604.   if (maintab->m_option10.m_ftpprox) 
  605.     ShellOptions->proxyftp = "%f";
  606.   else
  607.     ShellOptions->proxyftp = "%f0";   
  608.   
  609.   //depth
  610.   ShellOptions->depth = maintab->m_option5.m_depth;
  611.   ShellOptions->extdepth = maintab->m_option5.m_depth2;
  612.   
  613.   if(!maintab->m_option9.m_index) ShellOptions->index = "I0"; else ShellOptions->index = ""; 
  614.   if(!maintab->m_option9.m_index2) ShellOptions->index2 = "%I0"; else ShellOptions->index2 = "%I"; 
  615.   if(maintab->m_option2.m_dos) 
  616.     ShellOptions->dos = "L0"; 
  617.   else if(maintab->m_option2.m_iso9660) 
  618.     ShellOptions->dos = "L2"; 
  619.   else 
  620.     ShellOptions->dos = ""; 
  621.   if(maintab->m_option1.m_testall) ShellOptions->testall = "t"; else ShellOptions->testall = ""; 
  622.   if(maintab->m_option1.m_parseall) ShellOptions->parseall = "%P"; else ShellOptions->parseall = "%P0"; 
  623.   if(maintab->m_option1.m_link) ShellOptions->link = "n"; else ShellOptions->link = ""; 
  624.   if(maintab->m_option1.m_htmlfirst) ShellOptions->htmlfirst = "p7"; else ShellOptions->htmlfirst = ""; 
  625.   if(maintab->m_option2.m_errpage) ShellOptions->errpage = "o0"; else ShellOptions->errpage = ""; 
  626.   if(maintab->m_option2.m_external) ShellOptions->external = "x"; else ShellOptions->external = ""; 
  627.   if(maintab->m_option2.m_nopurge) ShellOptions->nopurge = "X0"; else ShellOptions->nopurge = ""; 
  628.   if(maintab->m_option2.m_hidepwd) ShellOptions->hidepwd = "%x"; else ShellOptions->hidepwd = ""; 
  629.   if(maintab->m_option2.m_hidequery) ShellOptions->hidequery = "%q0"; else ShellOptions->hidequery = ""; 
  630.   
  631.   ShellOptions->robots = "";
  632.   if(maintab->m_option8.m_robots==0) ShellOptions->robots = "s0"; 
  633.   else if(maintab->m_option8.m_robots==1) ShellOptions->robots = "s1"; 
  634.   else if(maintab->m_option8.m_robots==2) ShellOptions->robots = "s2"; 
  635.   
  636.   // cookies,checktype,parsejava
  637.   if(maintab->m_option8.m_cookies==0) ShellOptions->cookies = "b0"; // else ShellOptions->cookies = "b1";
  638.   if (maintab->m_option8.m_checktype>=0)
  639.     ShellOptions->checktype.Format("u%d",maintab->m_option8.m_checktype);
  640.   if(maintab->m_option8.m_parsejava==0) ShellOptions->parsejava = "j0"; // else ShellOptions->cookies = "j1";
  641.   if (maintab->m_option8.m_http10) ShellOptions->http10 = "%h";   // HTTP/1.0 notamment
  642.   if (maintab->m_option8.m_toler)  ShellOptions->toler = "%B";    // tolerent
  643.   if (maintab->m_option8.m_updhack)  ShellOptions->updhack = "%s";    // update hack
  644.   if (maintab->m_option8.m_urlhack)  ShellOptions->urlhack = "%u";    // URL hack
  645.   else                               ShellOptions->urlhack = "%u0";
  646.   
  647.   // store all in cache,logtype
  648.   if(maintab->m_option9.m_Cache2!=0) ShellOptions->Cache2 = "k";
  649.   if(maintab->m_option9.m_logtype==1) ShellOptions->logtype = "z";
  650.   else if(maintab->m_option9.m_logtype==2) ShellOptions->logtype = "Z";
  651.   if (maintab->m_option3.m_windebug) ShellOptions->logtype += "%H";      // debug headers
  652.   
  653.   ShellOptions->build = "";
  654.   if      (maintab->m_option2.m_build==0) ShellOptions->build = "N0";
  655.   else if (maintab->m_option2.m_build==1) ShellOptions->build = "N1";
  656.   else if (maintab->m_option2.m_build==2) ShellOptions->build = "N2";
  657.   else if (maintab->m_option2.m_build==3) ShellOptions->build = "N3";
  658.   else if (maintab->m_option2.m_build==4) ShellOptions->build = "N4";
  659.   else if (maintab->m_option2.m_build==5) ShellOptions->build = "N5";
  660.   else if (maintab->m_option2.m_build==6) ShellOptions->build = "N100";
  661.   else if (maintab->m_option2.m_build==7) ShellOptions->build = "N101";
  662.   else if (maintab->m_option2.m_build==8) ShellOptions->build = "N102";
  663.   else if (maintab->m_option2.m_build==9) ShellOptions->build = "N103";
  664.   else if (maintab->m_option2.m_build==10) ShellOptions->build = "N104";
  665.   else if (maintab->m_option2.m_build==11) ShellOptions->build = "N105";
  666.   else if (maintab->m_option2.m_build==12) ShellOptions->build = "N99";
  667.   else if (maintab->m_option2.m_build==13) ShellOptions->build = "N199";
  668.   else if (maintab->m_option2.m_build==14) {
  669.     ShellOptions->build = "-N \"";
  670.     ShellOptions->build += maintab->m_option2.Bopt.m_BuildString;
  671.     ShellOptions->build += "\"";
  672.   }
  673.   
  674.   ShellOptions->filtre = "";
  675.   if      (maintab->m_option3.m_filter==0) ShellOptions->filtre = "p0";
  676.   else if (maintab->m_option3.m_filter==1) ShellOptions->filtre = "p1";
  677.   else if (maintab->m_option3.m_filter==2) ShellOptions->filtre = "p2";
  678.   else if (maintab->m_option3.m_filter==3) {    /* default */
  679.     if(!maintab->m_option1.m_htmlfirst) ShellOptions->filtre = "p3";
  680.   }
  681.   else if (maintab->m_option3.m_filter==4) ShellOptions->filtre = "p7";
  682.   //
  683.   if      (maintab->m_option3.m_travel==0) ShellOptions->filtre += "S";
  684.   else if (maintab->m_option3.m_travel==1) ShellOptions->filtre += "D";
  685.   else if (maintab->m_option3.m_travel==2) ShellOptions->filtre += "U";
  686.   else if (maintab->m_option3.m_travel==3) ShellOptions->filtre += "B";
  687.   //
  688.   if      (maintab->m_option3.m_travel2==0) ShellOptions->filtre += "a";
  689.   else if (maintab->m_option3.m_travel2==1) ShellOptions->filtre += "d";
  690.   else if (maintab->m_option3.m_travel2==2) ShellOptions->filtre += "l";
  691.   else if (maintab->m_option3.m_travel2==3) ShellOptions->filtre += "e";
  692.   //
  693.   if      (maintab->m_option3.m_travel3==0) ShellOptions->filtre += "K0";
  694.   else if (maintab->m_option3.m_travel3==1) ShellOptions->filtre += "K";
  695.   else if (maintab->m_option3.m_travel3==2) ShellOptions->filtre += "K3";
  696.   else if (maintab->m_option3.m_travel3==3) ShellOptions->filtre += "K4";
  697.  
  698.   if (maintab->m_option9.m_logf) ShellOptions->log = "f2"; else ShellOptions->log = "Q"; 
  699.   
  700.   if(maintab->m_option5.m_sizemax!=""){
  701.     ShellOptions->max = "M";
  702.     ShellOptions->max += maintab->m_option5.m_sizemax;
  703.   } else ShellOptions->max = "";
  704.   
  705.   if(maintab->m_option5.m_pausebytes!=""){
  706.     ShellOptions->frag = "G";
  707.     ShellOptions->frag += maintab->m_option5.m_pausebytes;
  708.   } else ShellOptions->frag = "";
  709.   
  710.   
  711.   if(maintab->m_option5.m_maxhtml!="" || maintab->m_option5.m_othermax!="" ){
  712.     ShellOptions->maxfile = "m";
  713.     if(maintab->m_option5.m_othermax!="") ShellOptions->maxfile += maintab->m_option5.m_othermax;
  714.     else ShellOptions->maxfile += "0";
  715.     if(maintab->m_option5.m_maxhtml!="") {ShellOptions->maxfile += ",";ShellOptions->maxfile += maintab->m_option5.m_maxhtml;}
  716.     else {ShellOptions->maxfile += ",";ShellOptions->maxfile += "0";}
  717.   } else ShellOptions->maxfile = "";
  718.   
  719.   if(strcmp(maintab->m_option4.m_connexion,"")!=0){
  720.     ShellOptions->conn = "c";
  721.     ShellOptions->conn += maintab->m_option4.m_connexion;
  722.   } else ShellOptions->conn = "";
  723.   
  724.   if(strcmp(maintab->m_option4.m_timeout,"")!=0){
  725.     ShellOptions->time = "T";
  726.     ShellOptions->time += maintab->m_option4.m_timeout;
  727.   } else ShellOptions->time = "";
  728.   
  729.   // quitter host si timeout ou rate out
  730.   ShellOptions->hostquit = "";
  731.   {
  732.     int a=0;
  733.     if (maintab->m_option4.m_remt)
  734.       a+=1;
  735.     if (maintab->m_option4.m_rems)
  736.       a+=2;
  737.     ShellOptions->hostquit.Format("H%d",a);
  738.   }
  739.  
  740.   // Keep-Alive
  741.   if (maintab->m_option4.m_ka) {
  742.     ShellOptions->ka = "%k";
  743.   } else {
  744.     ShellOptions->ka = "%k0";
  745.   }
  746.  
  747.   
  748.   //--> max time
  749.   if(strcmp(maintab->m_option5.m_maxtime,"")!=0){
  750.     ShellOptions->maxtime = "E";
  751.     ShellOptions->maxtime += maintab->m_option5.m_maxtime;
  752.   } else ShellOptions->maxtime = "";
  753.   
  754.   //--> max rate
  755.   if(strcmp(maintab->m_option5.m_maxrate,"")!=0){
  756.     ShellOptions->maxrate = "A";
  757.     ShellOptions->maxrate += maintab->m_option5.m_maxrate;
  758.   } else ShellOptions->maxrate = "";
  759.   
  760.   if(strcmp(maintab->m_option5.m_maxconn,"")!=0){
  761.     ShellOptions->maxconn = "%c";
  762.     ShellOptions->maxconn += maintab->m_option5.m_maxconn;
  763.   } else ShellOptions->maxconn = "";
  764.   
  765.   if(strcmp(maintab->m_option5.m_maxlinks,"")!=0){
  766.     ShellOptions->maxlinks = "#L";
  767.     ShellOptions->maxlinks += maintab->m_option5.m_maxlinks;
  768.   } else ShellOptions->maxlinks = "";
  769.   
  770.   if(strcmp(maintab->m_option4.m_rate,"")!=0){
  771.     ShellOptions->rate = "J";
  772.     ShellOptions->rate += maintab->m_option4.m_rate;
  773.   } else ShellOptions->rate = "";
  774.   
  775.   if(strcmp(maintab->m_option6.m_user,"")!=0){
  776.     ShellOptions->user = "\"";
  777.     ShellOptions->user += maintab->m_option6.m_user;
  778.     ShellOptions->user += "\"";
  779.   } else ShellOptions->user = "";
  780.   
  781.   if(strcmp(maintab->m_option6.m_footer,"")!=0){
  782.     ShellOptions->footer = "\"";
  783.     ShellOptions->footer += maintab->m_option6.m_footer;
  784.     ShellOptions->footer += "\"";
  785.   } else ShellOptions->footer = "";
  786.   
  787.   if(strcmp(maintab->m_option4.m_retry,"")!=0){
  788.     ShellOptions->retry = "R";
  789.     ShellOptions->retry += maintab->m_option4.m_retry;
  790.   } else ShellOptions->retry = "";
  791.   
  792.   if(strcmp(maintab->m_option7.m_url2,"")!=0){
  793.     ShellOptions->buff_filtres = maintab->m_option7.m_url2;
  794.   } else ShellOptions->buff_filtres = "";
  795.   
  796.   
  797.   // MIME
  798.   ShellOptions->buff_MIME = "";
  799.   ADD_MIME_IN_COPT(1)
  800.     ADD_MIME_IN_COPT(2)
  801.     ADD_MIME_IN_COPT(3)
  802.     ADD_MIME_IN_COPT(4)
  803.     ADD_MIME_IN_COPT(5)
  804.     ADD_MIME_IN_COPT(6)
  805.     ADD_MIME_IN_COPT(7)
  806.     ADD_MIME_IN_COPT(8)
  807.     
  808.     /* autres options: RAS */
  809.     if (dialog2->m_rasdisc)
  810.       disconnect=1;     /* dΘconnexion α la fin */
  811.     else
  812.       disconnect=0;
  813.  
  814.     /* autres options: Shutdown */
  815.     if (dialog2->m_rasshut)
  816.       shutdown_pc=1;     /* Θtendre α la fin */
  817.     else
  818.       shutdown_pc=0;
  819. }
  820.  
  821. /* From MSDN: */
  822. void CALLBACK
  823. MessageBoxTimer(HWND hwnd, UINT uiMsg, UINT idEvent, DWORD dwTime)
  824. {
  825.   PostQuitMessage(0);
  826. }
  827. UINT
  828. TimedMessageBox(
  829.                 HWND hwndParent,
  830.                 LPCTSTR ptszMessage,
  831.                 LPCTSTR ptszTitle,
  832.                 UINT flags,
  833.                 DWORD dwTimeout)
  834. {
  835.   UINT idTimer;
  836.   UINT uiResult;
  837.   MSG msg;
  838.  
  839.   /*
  840.   *  Set a timer to dismiss the message box.
  841.   */ 
  842.   idTimer = SetTimer(NULL, 0, dwTimeout, (TIMERPROC)MessageBoxTimer);
  843.  
  844.   uiResult = MessageBox(hwndParent, ptszMessage, ptszTitle, flags);
  845.  
  846.   /*
  847.   *  Finished with the timer.
  848.   */ 
  849.   KillTimer(NULL, idTimer);
  850.  
  851.   /*
  852.   *  See if there is a WM_QUIT message in the queue. If so,
  853.   *  then you timed out. Eat the message so you don't quit the
  854.   *  entire application.
  855.   */ 
  856.   if (PeekMessage(&msg, NULL, WM_QUIT, WM_QUIT, PM_REMOVE)) {
  857.  
  858.     /*
  859.     *  If you timed out, then return zero.
  860.     */ 
  861.     uiResult = 0;
  862.   }
  863.  
  864.   return uiResult;
  865. }
  866.  
  867. /* From MSDN */
  868. BOOL InitiateSystemShutdownExWithPriv(
  869.   LPTSTR lpMessage,
  870.   DWORD dwTimeout,
  871.   BOOL bForceAppsClosed,
  872.   BOOL bRebootAfterShutdown,
  873.   DWORD dwReason)
  874. {
  875.    HANDLE hToken;              // handle to process token 
  876.    TOKEN_PRIVILEGES tkp;       // pointer to token structure 
  877.  
  878.    BOOL fResult;               // system shutdown flag 
  879.  
  880.    // Get the current process token handle so we can get shutdown 
  881.    // privilege. 
  882.  
  883.    if (!OpenProcessToken(GetCurrentProcess(), 
  884.         TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken)) 
  885.       return FALSE; 
  886.  
  887.    // Get the LUID for shutdown privilege. 
  888.  
  889.    LookupPrivilegeValue(NULL, SE_SHUTDOWN_NAME, 
  890.         &tkp.Privileges[0].Luid); 
  891.  
  892.    tkp.PrivilegeCount = 1;  // one privilege to set    
  893.    tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED; 
  894.  
  895.    // Get shutdown privilege for this process. 
  896.  
  897.    AdjustTokenPrivileges(hToken, FALSE, &tkp, 0, 
  898.       (PTOKEN_PRIVILEGES) NULL, 0); 
  899.  
  900.    // Cannot test the return value of AdjustTokenPrivileges. 
  901.  
  902.    if (GetLastError() != ERROR_SUCCESS) 
  903.       return FALSE; 
  904.  
  905.    // Display the shutdown dialog box and start the countdown. 
  906.  
  907. #if 0
  908.   fResult = InitiateSystemShutdownEx(
  909.     NULL,
  910.     lpMessage,
  911.     dwTimeout,
  912.     bForceAppsClosed,
  913.     bRebootAfterShutdown,
  914.     dwReason
  915.     );
  916. #else
  917. #ifndef EWX_FORCEIFHUNG
  918. #define EWX_FORCEIFHUNG     0x00000010
  919. #endif
  920.    UINT msgRes = TimedMessageBox(NULL, lpMessage, _T("Shutdown"), 
  921.      MB_OKCANCEL  | MB_SYSTEMMODAL | MB_ICONEXCLAMATION, 
  922.      dwTimeout*1000);
  923.      if (msgRes == 0 || msgRes == IDOK) {
  924.        fResult = ExitWindowsEx(EWX_LOGOFF | EWX_POWEROFF | EWX_FORCEIFHUNG, dwReason);
  925.      } else {
  926.        fResult = 0;
  927.      }
  928. #endif
  929.  
  930.    // Disable shutdown privilege.
  931.    tkp.Privileges[0].Attributes = 0; 
  932.    AdjustTokenPrivileges(hToken, FALSE, &tkp, 0, 
  933.         (PTOKEN_PRIVILEGES) NULL, 0); 
  934.  
  935.    if (!fResult) 
  936.       return FALSE; 
  937.    return TRUE; 
  938. }
  939.  
  940.  
  941. // Les routines α dΘfinir:
  942. int __cdecl httrackengine_check(char* adr,char* fil,int status) {  // appelΘ par le wizard
  943.   return -1;
  944. }
  945. int __cdecl httrackengine_check_mime(char* adr,char* fil,char* mime,int status) {  // appelΘ par le wizard
  946.   ATLTRACE(__FUNCTION__ " : check %s%s : <%s>\r\n", adr, fil, mime);
  947.   return -1;
  948. }
  949. EXECUTION_STATE (WINAPI * SetThreadExecutionState_)(IN EXECUTION_STATE) = NULL;
  950. void __cdecl httrackengine_init() {    // appelΘ lors de l'init de HTTRACK, avant le dΘbut d'un miroir
  951.   ATLTRACE(__FUNCTION__ " : init\r\n");
  952.   // Finished
  953.   PlaySound("MirrorStarted", NULL, SND_ASYNC | SND_NOWAIT | SND_APPLICATION);
  954.  
  955. #if USE_RAS
  956.   has_started=0;
  957. #endif
  958.  
  959.   /* Dynamic SetThreadExecutionState_ */
  960.   if (SetThreadExecutionState_ == NULL) {
  961.     HANDLE handle = LoadLibraryA("Kernel32.dll");
  962.     if (handle != INVALID_HANDLE_VALUE) {
  963.       SetThreadExecutionState_ = (EXECUTION_STATE (__stdcall *)(EXECUTION_STATE)) GetProcAddress((HMODULE)handle, "SetThreadExecutionState");
  964.     }
  965.   }
  966.  
  967.   httrackengine_loop(NULL,0,0,0,0,NULL,0);  // init
  968.   //printf("DEMARRAGE DU MIROIR DETECTE\n");  
  969. }
  970. void __cdecl httrackengine_uninit() {  // appelΘ en fin de miroir (peut Ωtre utile!!!)
  971.   ATLTRACE(__FUNCTION__ " : uninit\r\n");
  972.   // Finished
  973.   PlaySound("MirrorFinished", NULL, SND_ASYNC | SND_NOWAIT | SND_APPLICATION);
  974.  
  975.  // Disconnect RAS
  976. #if USE_RAS
  977.   if (LibRasUse) {        /* librairie RAS chargΘe */
  978.     if (disconnect) {     /* on doit dΘconnecter */
  979.       if (connected) {    /* on a initiΘ une connexion */
  980.         if (conn)
  981.           LibRas->RasHangUp(conn);
  982.       } else {            /* tout dΘconnecter */
  983.         // On coupe tout (non, pas bourrin)
  984.         DWORD size;
  985.         RASCONN* adr;
  986.         int count=256;
  987.         size = sizeof(RASCONN)*(count+2);
  988.         adr = (RASCONN*) (char*) calloc(size,1);
  989.         if (adr) {
  990.           DWORD ent;
  991.           int i;
  992.           for(i=0;i<count;i++) {
  993.             adr[i].dwSize=sizeof(RASCONN);
  994.             strcpybuff(adr[i].szEntryName,"");
  995.           }
  996.           if (LibRas->RasEnumConnections((RASCONN*) adr,&size,&ent) == 0) {
  997.             for(i=0;i<(int)ent;i++) {
  998.               LibRas->RasHangUp(adr[i].hrasconn);
  999.             }
  1000.           }
  1001.           free(adr);
  1002.         }
  1003.         
  1004.       }
  1005.     }
  1006.   }
  1007. #endif
  1008.  
  1009.   // Shutdown PC
  1010.   if (shutdown_pc) {
  1011.     //ExitWindowsEx(EWX_SHUTDOWN | EWX_POWEROFF | EWX_FORCEIFHUNG, 
  1012.     //  SHTDN_REASON_MAJOR_APPLICATION | SHTDN_REASON_MINOR_OTHER);
  1013.     InitiateSystemShutdownExWithPriv( 
  1014.       _T(
  1015.         "WinHTTrack has finished the mirror, the system will soon reboot.\r\n"
  1016.         "Click 'OK' to reboot.\r\n"
  1017.         "** CLICK NOW 'CANCEL' TO CANCEL THE REBOOT! **\r\n"
  1018.       ),
  1019.       6,
  1020.       TRUE /* bForceAppsClosed */,
  1021.       FALSE /* bRebootAfterShutdown */,
  1022.       SHTDN_REASON_MAJOR_APPLICATION | SHTDN_REASON_MINOR_OTHER
  1023.       );
  1024.   }
  1025. }
  1026. int __cdecl httrackengine_start(void* dummy) {   // appelΘ lors du dΘmarrage du miroir (premiΦres requΦtes)
  1027.   ATLTRACE(__FUNCTION__ " : starting\r\n");
  1028. #if USE_RAS
  1029.   // connexion RAS
  1030.   has_started=1;    // dΘmarrage
  1031.   connected=0;
  1032.   conn = NULL;
  1033.   memset(&SInfo, 0, sizeof(SInfo));
  1034.   if (LibRasUse) {
  1035.     if (ShellOptions->_RasString.GetLength()>0) {    // sΘlection provider
  1036.       if (!LibRas->RasDial(NULL,NULL,&ShellOptions->_dial,NULL,NULL,&conn)) {
  1037.         RASCONNSTATUS status;
  1038.         do {
  1039.           status.dwSize = sizeof(status);
  1040.           LibRas->RasGetConnectStatus(conn,&status);
  1041.           switch(status.rasconnstate) {
  1042.           case RASCS_Connected : 
  1043.             connected=1;
  1044.             break;
  1045.           case RASCS_Disconnected :
  1046.             strcpybuff(connected_err,LANG(LANG_F3 /*"Could not connect to provider"*/));
  1047.             connected=-1;
  1048.             break;
  1049.           }
  1050.         } while(connected==0);
  1051.       } else {
  1052.         strcpybuff(connected_err,LANG(LANG_F3 /*"Could not connect to provider","Impossible d'Θtablir la connexion"*/));
  1053.         connected=-1;
  1054.         //termine=1;
  1055.       }
  1056.     }
  1057.     //
  1058.     if (connected != -1)  // si pas d'erreur RAS
  1059.       return 1;
  1060.     else
  1061.       return 0;
  1062.   } else
  1063.     return 1;
  1064. #else
  1065.   return 1;
  1066. #endif
  1067. }
  1068. int  httrackengine_end() {     // appelΘ lors de la fin du miroir (plus de liens α charger)
  1069.   ATLTRACE(__FUNCTION__ " : end\r\n");
  1070.   WHTT_LOCK();
  1071.   termine=1;
  1072.   if (_Cinprogress_inst) {
  1073.     _Cinprogress_inst->EndDialog(IDOK);
  1074.     _Cinprogress_inst=NULL;
  1075.   }
  1076.   WHTT_UNLOCK();
  1077.   return 1;
  1078. }
  1079. int __cdecl httrackengine_htmlpreprocess(char** html,int* len,char* url_adresse,char* url_fichier) {
  1080.   ATLTRACE(__FUNCTION__ " : preprocessing %s%s (%d bytes)\r\n", url_adresse, url_fichier, *len);
  1081.   return 1;
  1082. }
  1083. int __cdecl httrackengine_htmlpostprocess(char** html,int* len,char* url_adresse,char* url_fichier) {
  1084.   ATLTRACE(__FUNCTION__ " : postprocessing %s%s (%d bytes)\r\n", url_adresse, url_fichier, *len);
  1085.   return 1;
  1086. }
  1087. int __cdecl httrackengine_htmlcheck(char* html,int len,char* url_adresse,char* url_fichier) {    // appelΘ α chaque fois qu'un html doit Ωtre scannΘ (utile pour la prospection mais inutile ici)
  1088.   return 1;
  1089. }
  1090. int __cdecl httrackengine_chopt(void* opt) {
  1091.   ATLTRACE(__FUNCTION__ " : changing options\r\n");
  1092.   return 1;
  1093. }
  1094. void __cdecl httrackengine_filesave(char* file) {
  1095. }
  1096. void __cdecl httrackengine_filesave2(char* adr, char* fil, char* save, int is_new, int is_modified, int not_updated) {
  1097.   ATLTRACE(__FUNCTION__ " : saving %s%s as %s (new=%d, modified=%d, notupdated=%d)\r\n", adr, fil, save, is_new, is_modified, not_updated);
  1098. }
  1099.  
  1100. // Le routine la plus utile sans doute: elle refresh les tableaux
  1101. // C'est la 2e routine en thread qui assure le refresh graphique
  1102. // (plus efficace)
  1103. // -->C'est elle qui dΘcide de tout arrΩter si elle dΘtecte in termine_request<--
  1104. int __cdecl httrackengine_loop(
  1105.                                void* _back,int back_max,int back_index,
  1106.                                int lien_n,int lien_tot,
  1107.                                int stat_time,
  1108.                                hts_stat_struct* stats) {    // appelΘ α chaque boucle de HTTrack
  1109.   static char s[HTS_URLMAXSIZE*2]="";  // utilisΘ plus loin
  1110.   int stat_written=-1;
  1111.   int stat_updated=-1;
  1112.   int stat_errors=-1;
  1113.   int stat_warnings=-1;
  1114.   int stat_infos=-1;
  1115.   int nbk=-1;
  1116.   LLint nb=-1;
  1117.   int stat_nsocket=-1;
  1118.   LLint stat_bytes=-1;
  1119.   LLint stat_bytes_recv=-1;
  1120.   int irate=-1;
  1121.  
  1122.   /* Mutex */
  1123.   WHTT_LOCK();
  1124.  
  1125.   /* Forces the system to be in the working state by resetting the system idle timer. */
  1126.   if (SetThreadExecutionState_ != NULL)
  1127.     SetThreadExecutionState_(ES_SYSTEM_REQUIRED);
  1128.  
  1129.   if (stats) {
  1130.     stat_written=stats->stat_files;
  1131.     stat_updated=stats->stat_updated_files;
  1132.     stat_errors=stats->stat_errors;
  1133.     stat_warnings=stats->stat_warnings;
  1134.     stat_infos=stats->stat_infos;
  1135.     nbk=stats->nbk;
  1136.     stat_nsocket=stats->stat_nsocket;
  1137.     irate=(int)stats->rate;
  1138.     nb=stats->nb;
  1139.     stat_bytes=stats->nb;
  1140.     stat_bytes_recv=stats->HTS_TOTAL_RECV;
  1141.   }
  1142.   
  1143. #if !SHELL_MULTITHREAD
  1144.   static TStamp last_time;
  1145. #endif
  1146.   int rate;
  1147.   // casts
  1148.   lien_back* back=(lien_back*) _back;
  1149.   //  static int ft=-1;
  1150.   
  1151.   if (back_max == 0) {
  1152. #if !SHELL_MULTITHREAD
  1153.     last_time=0;
  1154. #endif
  1155.     // en cas de manque de time
  1156.     SInfo.refresh=1;
  1157.     SInfo.stat_timestart=time_local();
  1158.     WHTT_UNLOCK();
  1159.     return 1;
  1160.   }
  1161.   
  1162.   if ((termine) || (termine_requested)) {
  1163.     SInfo.refresh=0;      // pas de refresh
  1164.     SInfo.refresh=0;      // pas de refresh
  1165.     termine_requested=1;
  1166.     WHTT_UNLOCK();
  1167.     return 0;
  1168.   }
  1169.   
  1170.   if (stat_written>=0) SInfo.stat_written=stat_written;
  1171.   if (stat_updated>=0) SInfo.stat_updated=stat_updated;
  1172.   if (stat_errors>=0)  SInfo.stat_errors=stat_errors;
  1173.   if (stat_warnings>=0)  SInfo.stat_warnings=stat_warnings;
  1174.   if (stat_infos>=0)  SInfo.stat_infos=stat_infos;
  1175.   
  1176. #if SHELL_MULTITHREAD 
  1177.   //if (((tl-last_time)>=100) || ((tl-last_time)<0)) {   // chaque 100 ms
  1178.   if (SInfo.ask_refresh) {
  1179. #else
  1180.     TStamp tl=0;
  1181.     {
  1182.       time_t tt;
  1183.       struct tm* A;
  1184.       tt=time(NULL);
  1185.       A=localtime(&tt);
  1186.       tl+=A->tm_sec;
  1187.       tl+=A->tm_min*60;
  1188.       tl+=A->tm_hour*60*60;
  1189.       //tl+=A->tm_yday*60*60*24;
  1190.       //tl+=A->tm_year*60*60*24*365;
  1191.       
  1192.       tl*=1000;  // en ms
  1193.       
  1194.       struct _timeb timebuffer;
  1195.       char *timeline;
  1196.       _ftime( &timebuffer );
  1197.       timeline = ctime( & ( timebuffer.time ) );
  1198.       
  1199.       tl+=timebuffer.millitm;    // + ms
  1200.     }
  1201.     if (((tl-last_time)>=HTS_SLEEP_WIN) || ((tl-last_time)<0)) {   // chaque 250 ms
  1202.       last_time=tl;
  1203. #endif
  1204.       //INFILLMEM_LOCKED=1;    // locker interface
  1205.       // OPTI int rate;
  1206.       SInfo.ask_refresh=0;
  1207.       
  1208.       // pour Θviter temps cpu consommΘ trop grand
  1209.       // Sleep(10);
  1210.       
  1211.       // initialiser ft
  1212.       if ((stat_nsocket==-1)) {
  1213.         if (SInfo.ft==-1) {
  1214.           SInfo.ft=stat_time;
  1215.         }
  1216.       }
  1217.       
  1218. #if !SHELL_MULTITHREAD
  1219.       //
  1220.       MSG msg;  
  1221.       if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE )) {     
  1222.         switch (msg.message) {
  1223.         case WM_COMMAND:        
  1224.           switch(msg.wParam) { 
  1225.           case ID_APP_ABOUT: {
  1226.             Cabout about;
  1227.             about.DoModal();                                    }
  1228.             break;
  1229.           case ID_APP_EXIT: case WM_CLOSE :
  1230.             termine_requested=1;
  1231.             break;
  1232.           case  WM_DESTROY: case WM_NCDESTROY: 
  1233.             termine_requested=1;
  1234.             break;
  1235.           }
  1236.           break;        
  1237.           default:
  1238.             DefWindowProc(msg.hwnd,msg.message,msg.wParam,msg.lParam);
  1239.             break;
  1240.         }
  1241.       }
  1242.       //
  1243. #endif
  1244.       
  1245.       // calculer heure si ce n'est dΘja fait
  1246.       if (stat_time<0)
  1247.         SInfo.stat_time=(int) (time_local()-SInfo.stat_timestart);
  1248.       
  1249.       // calculer transfer rate
  1250.       if ((stat_time>0) && (stat_bytes_recv>0))
  1251.         rate=(int)(stat_bytes_recv/stat_time);
  1252.       else
  1253.         rate=0;    // pas d'infos
  1254.       
  1255.       // stocker infos: octets transfΘrΘs, temps, etc.
  1256.       if (stat_bytes>=0) SInfo.stat_bytes=stat_bytes;      // bytes
  1257.       if (stat_time>=0) SInfo.stat_time=stat_time;         // time
  1258.       if (lien_tot>=0) SInfo.lien_tot=lien_tot; // nb liens
  1259.       if (lien_n>=0) SInfo.lien_n=lien_n;       // scanned
  1260.       SInfo.stat_nsocket=stat_nsocket;          // socks
  1261.       if (rate>0)  SInfo.rate=rate;                // rate
  1262.       if (irate>=0) SInfo.irate=irate;             // irate
  1263.       if (SInfo.irate<0) SInfo.irate=SInfo.rate;
  1264.       if (nbk>=0) SInfo.stat_back=nbk;
  1265.       
  1266.       // back: tableau de back_max ΘlΘments de cache
  1267.       // back_max: nombre d'ΘlΘments ^^^^
  1268.       // lien_tot: nombre total de liens traitΘs pour le moment
  1269.       // stat_bytes: octets sauvegardΘs
  1270.       // stat_bytes_recv: octets tΘlΘchargΘs
  1271.       // stat_time: temps en seconde depuis le dΘbut du miroir
  1272.       // stat_nsocket: nombre de sockets connectΘes actuellement
  1273.       // on peut en dΘduire rate=stat_bytes_recv/stat_time
  1274.       
  1275.       // printf("loop.. %d liens, %d octets, %d secondes, %d sockets, TAUX=%d\n",lien_tot,stat_bytes,stat_time,stat_nsocket,rate);
  1276.       
  1277.       // parcourir registre des liens
  1278.       if (back_index>=0) {  // seulement si index passΘ
  1279.         int j,k;
  1280.         int index=0;
  1281.         int ok=0;         // idem
  1282.         int l;            // idem
  1283.         int M=32;         // idem
  1284.         
  1285.         StatsBufferback=(void*) back;
  1286.         StatsBufferback_max=back_max;
  1287.         {
  1288.           int i;
  1289.           for(i=0;i<NStatsBuffer;i++) {
  1290.             strcpybuff(StatsBuffer[i].etat,"");
  1291.             strcpybuff(StatsBuffer[i].nom,"");
  1292.             strcpybuff(StatsBuffer[i].fichier,"");
  1293.             strcpybuff(StatsBuffer[i].url_sav,"");
  1294.             StatsBuffer[i].back=NULL;
  1295.             StatsBuffer[i].size=0;
  1296.             StatsBuffer[i].sizetot=0;
  1297.           }
  1298.         }
  1299.         for(k=0;k<2;k++) {    // 0: lien en cours 1: autres liens
  1300.           for(j=0;(j<3) && (index<NStatsBuffer);j++) {  // passe de prioritΘ
  1301.             int _i;
  1302.             for(_i=0+k;(_i< max(back_max*k,1) ) && (index<NStatsBuffer);_i++) {  // no lien
  1303.               int i=(back_index+_i)%back_max;    // commencer par le "premier" (l'actuel)
  1304.               if (back[i].status>=0) {     // signifie "lien actif"
  1305.                 // int ok=0;  // OPTI
  1306.                 ok=0;
  1307.                 switch(j) {
  1308.                 case 0:     // prioritaire
  1309.                   if ((back[i].status>0) && (back[i].status<99)) {
  1310.                     strcpybuff(StatsBuffer[index].etat,LANG(LANG_F4 /*"receive","rΘception"*/)); ok=1;
  1311.                   }
  1312.                   break;
  1313.                 case 1:
  1314.                   if (back[i].status==99) {
  1315.                     strcpybuff(StatsBuffer[index].etat,LANG(LANG_F5 /*"request","requΦte"*/)); ok=1;
  1316.                   }
  1317.                   else if (back[i].status==100) {
  1318.                     strcpybuff(StatsBuffer[index].etat,LANG(LANG_F6 /*"connect","connexion"*/)); ok=1;
  1319.                   }
  1320.                   else if (back[i].status==101) {
  1321.                     strcpybuff(StatsBuffer[index].etat,LANG(LANG_F7 /*"search","recherche"*/)); ok=1;
  1322.                   }
  1323.                   else if (back[i].status==1000) {    // ohh le beau ftp
  1324.                                         char proto[] = "ftp";
  1325.                                         if (back[i].url_adr[0]) {
  1326.                                             char* ep = strchr(back[i].url_adr, ':');
  1327.                                             char* eps = strchr(back[i].url_adr, '/');
  1328.                                             int count;
  1329.                                             if (ep != NULL && ep < eps && (count = (ep - back[i].url_adr) ) < 4) {
  1330.                                                 proto[0] = '\0';
  1331.                                                 strncat(proto, back[i].url_adr, count);
  1332.                                             }
  1333.                                         }
  1334.                     sprintf(StatsBuffer[index].etat,"%s: %s",proto,back[i].info); ok=1;
  1335.                   }
  1336.                   else if (back[i].status==102) {         // SSL handshake
  1337.                     strcpybuff(StatsBuffer[index].etat,LANG(LANG_F6 /*"connect","connexion"*/)); ok=1;
  1338.                   }
  1339.                   else if (back[i].status==-103) {         // waiting (keep-alive)
  1340.                     strcpybuff(StatsBuffer[index].etat,LANG(LANG_F8)); ok=1;
  1341.                   }
  1342.                   break;
  1343.                 default:
  1344.                   if (back[i].status==0) {  // prΩt
  1345.                     if ((back[i].r.statuscode==200)) {
  1346.                       strcpybuff(StatsBuffer[index].etat,LANG(LANG_F8 /*"ready","prΩt"*/)); ok=1;
  1347.                     }
  1348.                     else if ((back[i].r.statuscode>=100) && (back[i].r.statuscode<=599)) {
  1349.                       char tempo[256]; tempo[0]='\0';
  1350.                       infostatuscode(tempo,back[i].r.statuscode);
  1351.                       strcpybuff(StatsBuffer[index].etat,tempo); ok=1;
  1352.                     }
  1353.                     else {
  1354.                       strcpybuff(StatsBuffer[index].etat,LANG(LANG_F9 /*"error","erreur"*/)); ok=1;
  1355.                     }
  1356.                   }
  1357.                   break;
  1358.                 }
  1359.                 
  1360.                 if (ok) {
  1361.                   // OPTI int l;
  1362.                   // OPTI int M=32;     // longueur
  1363.                   // OPTI char s[HTS_URLMAXSIZE*2]="";
  1364.                   //
  1365.                   StatsBuffer[index].back=i;        // index pour + d'infos
  1366.                   //
  1367.                   s[0]='\0';
  1368.                   strcpybuff(StatsBuffer[index].url_sav,back[i].url_sav);   // pour cancel
  1369.                   if (strcmp(back[i].url_adr,"file://"))
  1370.                     strcatbuff(s,back[i].url_adr);
  1371.                   else
  1372.                     strcatbuff(s,"localhost");
  1373.                   if (back[i].url_fil[0]!='/')
  1374.                     strcatbuff(s,"/");
  1375.                   strcatbuff(s,back[i].url_fil);
  1376.                   
  1377.                   StatsBuffer[index].fichier[0]='\0';
  1378.                   {
  1379.                     char* a=strrchr(s,'/');
  1380.                     if (a) {
  1381.                       strncatbuff(StatsBuffer[index].fichier,a,200);
  1382.                       *a='\0';
  1383.                     }
  1384.                   }
  1385.                   
  1386.                   if ((l=strlen(s))<MAX_LEN_INPROGRESS)
  1387.                     strcpybuff(StatsBuffer[index].nom,s);
  1388.                   else {
  1389.                     // couper
  1390.                     StatsBuffer[index].nom[0]='\0';
  1391.                     strncatbuff(StatsBuffer[index].nom,s,MAX_LEN_INPROGRESS/2-2);
  1392.                     strcatbuff(StatsBuffer[index].nom,"...");
  1393.                     strcatbuff(StatsBuffer[index].nom,s+l-MAX_LEN_INPROGRESS/2+2);
  1394.                   }
  1395.                   
  1396.                   //if (back[i].url_fil[0]!='/') printf("/");
  1397.                   
  1398.                   if (back[i].r.totalsize>0) {  // taille prΘdΘfinie
  1399.                     StatsBuffer[index].sizetot=back[i].r.totalsize;
  1400.                     StatsBuffer[index].size=back[i].r.size;
  1401.                   } else {  // pas de taille prΘdΘfinie
  1402.                     if (back[i].status==0) {  // prΩt
  1403.                       StatsBuffer[index].sizetot=back[i].r.size;
  1404.                       StatsBuffer[index].size=back[i].r.size;
  1405.                     } else {
  1406.                       StatsBuffer[index].sizetot=8192;
  1407.                       StatsBuffer[index].size=(back[i].r.size % 8192);
  1408.                     }
  1409.                   }
  1410.                   index++;
  1411.                 }
  1412.               }
  1413.             }
  1414.           }
  1415.         }
  1416.     }
  1417.     
  1418. #if SHELL_MULTITHREAD
  1419.     SInfo.refresh=1;     // on signale qu'il faut faire un refresh!
  1420. #else
  1421.     inprogress_refresh();  // tout de suite (non multithread)
  1422. #endif
  1423.     // INFILLMEM_LOCKED=0;    // dΘlocker interface
  1424.   }
  1425.   WHTT_UNLOCK();
  1426.   return (termine==0);
  1427. }
  1428.  
  1429. int inprogress_refresh() {
  1430.   static int toggle=0;
  1431.   // WHTT_LOCK(); // deja fait
  1432.   if ((!termine) && (!termine_requested) && (inprogress->m_hWnd)) {
  1433.     if (SInfo.refresh) {
  1434.       // INREDRAW_LOCKED=1;
  1435.       // REFRESH (si nb de socket==-1 on manage les fenetres)
  1436.       int icn;
  1437.       icn=inprogress->IsIconic();
  1438.       CString lnk;
  1439.       if (SInfo.stat_back)
  1440.         lnk.Format("%d/%d (+%d)",SInfo.lien_n,SInfo.lien_tot-1,SInfo.stat_back);
  1441.       else
  1442.         lnk.Format("%d/%d",SInfo.lien_n,SInfo.lien_tot-1);
  1443.       if (!icn) {
  1444.         int parsing=0;
  1445.         if (!soft_term_requested) {
  1446.           if (!hts_setpause(-1)) {
  1447.             if (!(parsing=hts_is_parsing(-1)))
  1448.               SetDlgItemTextCP(inprogress, IDC_inforun,LANG(LANG_F10 /*"Receiving files.","RΘception des fichiers"*/)); 
  1449.             else {
  1450.               switch(hts_is_testing()) {
  1451.               case 0:
  1452.                 SetDlgItemTextCP(inprogress, IDC_inforun,LANG(LANG_F11 /*"Parsing HTML file..","Parcours du fichier HTML"*/)); 
  1453.                 break;
  1454.               case 1:
  1455.                 SetDlgItemTextCP(inprogress, IDC_inforun,LANG(LANG_F12 /*"Parsing HTML file (testing links)..","Parcours du fichier HTML (test des liens)"*/)); 
  1456.                 break;
  1457.               case 2:
  1458.                 SetDlgItemTextCP(inprogress, IDC_inforun,LANG(LANG_F11b)); 
  1459.                 break;
  1460.               case 3:
  1461.                 SetDlgItemTextCP(inprogress, IDC_inforun,LANG(LANG_F11c)); 
  1462.                 break;
  1463.               case 4:
  1464.                 SetDlgItemTextCP(inprogress, IDC_inforun,LANG(LANG_F15)); 
  1465.                 break;
  1466.               case 5:
  1467.                 SetDlgItemTextCP(inprogress, IDC_inforun,LANG(LANG_F15b)); 
  1468.                 break;
  1469.               }
  1470.             }
  1471.           } else {
  1472.             if (((toggle++)/5)%2)
  1473.               SetDlgItemTextCP(inprogress, IDC_inforun,LANG(LANG_F13 /*"Paused (select [File]/[Pause transfer] to continue)","Interrompu (choisir [Fichier]/[Interrompre transferts] pour continuer)"*/));
  1474.             else
  1475.               SetDlgItemTextCP(inprogress, IDC_inforun,"");
  1476.           }
  1477.         } else {
  1478.           if (((toggle++)/5)%2)
  1479.             SetDlgItemTextCP(inprogress, IDC_inforun,LANG(LANG_F13b));
  1480.           else
  1481.             SetDlgItemTextCP(inprogress, IDC_inforun,"");
  1482.         }
  1483.         
  1484.         if (SInfo.stat_time>0) {
  1485.           char s[256];
  1486.           qsec2str(s,(TStamp) SInfo.stat_time);
  1487.           SetDlgItemTextCP(inprogress, IDC_i1 ,s);  // time
  1488.         } else
  1489.           SetDlgItemTextCP(inprogress, IDC_i1 , _SN(SInfo.stat_time) );  // time
  1490.         SetDlgItemTextCP(inprogress, IDC_i0 , int2bytes(SInfo.stat_bytes) );  // bytes
  1491.         SetDlgItemTextCP(inprogress, IDC_i2 , lnk);  // scanned
  1492.         if (SInfo.stat_nsocket>0)
  1493.           SetDlgItemTextCP(inprogress, IDC_i3 , _SN(SInfo.stat_nsocket) );  // socks
  1494.         else
  1495.           SetDlgItemTextCP(inprogress, IDC_i3 , "none" );  // wait
  1496.         
  1497.         CString st;
  1498.         st.Format("%s (%s)",int2bytessec(SInfo.irate),int2bytessec(SInfo.rate));
  1499.         SetDlgItemTextCP(inprogress, IDC_i4 , st );  // rate
  1500.         
  1501.         SetDlgItemTextCP(inprogress, IDC_i5 , _SN(SInfo.stat_errors) );
  1502.         SetDlgItemTextCP(inprogress, IDC_i6 , _SN(SInfo.stat_written) );
  1503.         {
  1504.           char tempo[256];
  1505.           int pc=0;
  1506.           if (SInfo.stat_written)
  1507.             pc=(int)((SInfo.stat_updated*100)/(SInfo.stat_written));
  1508.           if (pc)
  1509.             sprintf(tempo,"%d (%d%%)",SInfo.stat_updated,pc);
  1510.           else
  1511.             sprintf(tempo,"%d",SInfo.stat_updated);
  1512.           SetDlgItemTextCP(inprogress, IDC_i7 , tempo );
  1513.         }
  1514.         
  1515.         /*if (!parsing)*/
  1516.         {
  1517.           {
  1518.             int i;
  1519.             for(i=0;i<NStatsBuffer;i++) {
  1520.               if (StatsBuffer[i].sizetot>0) {
  1521.                 TStamp d = ((TStamp) StatsBuffer[i].size * 1000);
  1522.                 d = d / ((TStamp) StatsBuffer[i].sizetot);
  1523.                 StatsBuffer[i].offset = (int) d;
  1524.               } else
  1525.                 StatsBuffer[i].offset = 0;
  1526.             }
  1527.           }
  1528.           
  1529.           if (!parsing)
  1530.             inprogress->m_sl0.SetRange(0,1000);
  1531.           inprogress->m_sl1.SetRange(0,1000);
  1532.           inprogress->m_sl2.SetRange(0,1000);
  1533.           inprogress->m_sl3.SetRange(0,1000);
  1534.           inprogress->m_sl4.SetRange(0,1000);
  1535.           inprogress->m_sl5.SetRange(0,1000);
  1536.           inprogress->m_sl6.SetRange(0,1000);
  1537.           inprogress->m_sl7.SetRange(0,1000);
  1538.           inprogress->m_sl8.SetRange(0,1000);
  1539.           inprogress->m_sl9.SetRange(0,1000);
  1540.           inprogress->m_sl10.SetRange(0,1000);
  1541.           inprogress->m_sl11.SetRange(0,1000);
  1542.           inprogress->m_sl12.SetRange(0,1000);
  1543.           inprogress->m_sl13.SetRange(0,1000);
  1544.           
  1545.           if (!parsing)
  1546.             inprogress->m_sl0.SetPos(StatsBuffer[0].offset);
  1547.           inprogress->m_sl1.SetPos(StatsBuffer[1].offset);
  1548.           inprogress->m_sl2.SetPos(StatsBuffer[2].offset);
  1549.           inprogress->m_sl3.SetPos(StatsBuffer[3].offset);
  1550.           inprogress->m_sl4.SetPos(StatsBuffer[4].offset);
  1551.           inprogress->m_sl5.SetPos(StatsBuffer[5].offset);
  1552.           inprogress->m_sl6.SetPos(StatsBuffer[6].offset);
  1553.           inprogress->m_sl7.SetPos(StatsBuffer[7].offset);
  1554.           inprogress->m_sl8.SetPos(StatsBuffer[8].offset);
  1555.           inprogress->m_sl9.SetPos(StatsBuffer[9].offset);
  1556.           inprogress->m_sl10.SetPos(StatsBuffer[10].offset);
  1557.           inprogress->m_sl11.SetPos(StatsBuffer[11].offset);
  1558.           inprogress->m_sl12.SetPos(StatsBuffer[12].offset);
  1559.           inprogress->m_sl13.SetPos(StatsBuffer[13].offset);
  1560.           
  1561.           // redraw en boucle
  1562.           {
  1563.             int i=0;
  1564.             if (parsing)
  1565.               i++;
  1566.             for( ; i<NStatsBuffer;i++) {
  1567.               CString st;
  1568.               st = StatsBuffer[i].etat;
  1569.               st.Replace("&", "&&");
  1570.               SetWindowTextCP(inprogress->element[0][i], st);
  1571.               st = StatsBuffer[i].nom;
  1572.               st.Replace("&", "&&");
  1573.               SetWindowTextCP(inprogress->element[1][i], st);
  1574.               st = StatsBuffer[i].fichier;
  1575.               st.Replace("&", "&&");
  1576.               SetWindowTextCP(inprogress->element[4][i], st);
  1577.               
  1578.               if ((strlen(StatsBuffer[i].etat)==0) != StatsBuffer[i].actived) {
  1579.                 StatsBuffer[i].actived=!StatsBuffer[i].actived;
  1580.                 if (!StatsBuffer[i].actived)
  1581.                   inprogress->element[3][i]->ModifyStyle(WS_DISABLED,0);
  1582.                 else
  1583.                   inprogress->element[3][i]->ModifyStyle(0,WS_DISABLED);
  1584.                 inprogress->element[3][i]->RedrawWindow();
  1585.               }
  1586.             }
  1587.           }
  1588.           //
  1589.         }
  1590.         /* else*/
  1591.         if (parsing) {  // parsing
  1592.           //
  1593.           inprogress->m_sl0.SetRange(0,100);
  1594.           inprogress->m_sl0.SetPos(parsing);
  1595.           SetWindowTextCP(inprogress->element[0][0], LANG(LANG_F14 /*"scanning","parcours"*/));
  1596.           SetWindowTextCP(inprogress->element[1][0], StatsBuffer[0].nom);
  1597.           SetWindowTextCP(inprogress->element[4][0], "");
  1598.           //inprogress->element[0][1]->SetWindowTextCP(this, );
  1599.         }
  1600.         
  1601.       }
  1602.       {
  1603.         static char last_info[256]="";
  1604.         char info[256];
  1605.         if ((SInfo.stat_nsocket==-1)) {
  1606. #if USE_RAS
  1607.           if (!has_started)
  1608. #endif
  1609.             SetDlgItemTextCP(inprogress, IDC_nm0,LANG(LANG_F15 /*"Waiting for specific hour to start","Attente de l'heure programmΘe pour dΘmarrer"*/));
  1610. #if USE_RAS
  1611.           else
  1612.             SetDlgItemTextCP(inprogress, IDC_nm0,LANG(LANG_F16 /*"Connecting to provider","Connexion au provider"*/));
  1613. #endif
  1614.           inprogress->m_sl0.SetRange(0,SInfo.ft);
  1615.           inprogress->m_sl0.SetPos(SInfo.ft-SInfo.stat_time);  // temps restant
  1616.           // SetDlgItemTextCP(inprogress, IDC_nm1,_SN(ft));
  1617.           if (icn && (!this_CSplitterFrame->iconifie)) {  // minimisΘe mais pas en icone
  1618.             sprintf(info,"[%d s]",SInfo.stat_time);
  1619.           } else {
  1620.             sprintf(info,LANG(LANG_F17 /*"Mirror waiting [%d seconds]","Miroir en attente [%d secondes]"*/),SInfo.stat_time);
  1621.           }
  1622.         } else {
  1623.           if (icn) {  // minimisΘe
  1624.             sprintf(info,"[%s]",lnk);
  1625.           } else {
  1626.             char byteb[256];
  1627.             sprintf(byteb, LLintP, SInfo.stat_bytes);
  1628.             sprintf(info,LANG(LANG_F18),lnk,byteb);
  1629.           }
  1630.         }
  1631.         if (strcmp(info,last_info)) {       /* a changΘ */
  1632.           strcpybuff(last_info,info);           /* recopier */
  1633.           if (this_CSplitterFrame->iconifie)  // minimisΘ icone
  1634.             this_CSplitterFrame->IconChange(last_info);
  1635.           else
  1636.             SetWindowTextCP(GetMainWindow(), last_info);
  1637.         }
  1638.       }  
  1639.       
  1640.       //inprogress->UpdateWindow();
  1641.     } else {
  1642.     }
  1643.   }
  1644.   // WHTT_UNLOCK();
  1645.   return 1;
  1646. }
  1647.  
  1648. /*
  1649. // refresh scan
  1650. int inprogress_refresh_scan() {
  1651. if ((!termine) && (!termine_requested) && (inprogress->m_hWnd)) {
  1652. if (!SInfo.refresh) {
  1653. if (!inprogress->IsIconic()) {
  1654. int n;
  1655. // patch pour le scanning
  1656. if (n=hts_is_parsing()) {
  1657. strcpybuff(StatsBuffer[0].etat,"scanning");
  1658. inprogress->element[0][0]->SetWindowTextCP(this, "scanning");
  1659. StatsBuffer[0].sizetot=100;
  1660. StatsBuffer[0].size=n;
  1661. inprogress->m_sl0.SetRange(0,100);  // progression en % du scanning
  1662. inprogress->m_sl0.SetPos(n);
  1663. //} else {
  1664. //  inprogress->element[0][0]->SetWindowTextCP(this, "...");
  1665. }
  1666. }
  1667. }
  1668. }
  1669. return 1;
  1670. }
  1671. */
  1672.  
  1673. /* Plantages si DoModal() dans un thread != du principal.. passons.. */
  1674. char* __cdecl httrackengine_query(char* question) {
  1675.   strcpybuff(WIZ_question,question);
  1676.   strcpybuff(WIZ_reponse, "");
  1677.   // AfxGetMainWnd()
  1678.   CWnd* wnd = GetMainWindow();
  1679.   if (wnd) {
  1680.     wnd->SendMessage(WM_COMMAND,wm_WizRequest1,0);
  1681.   }
  1682.   return WIZ_reponse;
  1683. }
  1684.  
  1685. char* __cdecl httrackengine_query2(char* question) {
  1686.   strcpybuff(WIZ_question,question);
  1687.   strcpybuff(WIZ_reponse, "");
  1688.   // AfxGetMainWnd()
  1689.   CWnd* wnd = GetMainWindow();
  1690.   if (wnd) {
  1691.     wnd->SendMessage(WM_COMMAND,wm_WizRequest2,0);
  1692.   }
  1693.   return WIZ_reponse;
  1694. }
  1695.  
  1696. char* __cdecl httrackengine_query3(char* question) {
  1697.   strcpybuff(WIZ_question,question);
  1698.   strcpybuff(WIZ_reponse, "");
  1699.   CWnd* wnd = GetMainWindow();
  1700.   if (wnd) {
  1701.     wnd->SendMessage(WM_COMMAND,wm_WizRequest3,0);
  1702.   }
  1703.   return WIZ_reponse;
  1704. }
  1705.  
  1706. void __cdecl httrackengine_pause(char* lockfile) {
  1707.   ATLTRACE(__FUNCTION__ " : pause\r\n");
  1708.   AfxMessageBox("Engine paused.. click OK to continue!",MB_OK);
  1709.   remove(lockfile);
  1710. }
  1711.  
  1712. // modif RX 10/10/98 pour gestion des , et des tabs
  1713. static void StripControls(char* chaine)
  1714. {
  1715.   for(int i=0 ; chaine[i] != '\0' ; i++)
  1716.   {
  1717.     if(chaine[i]=='\n' || chaine[i]==13 || chaine[i]==9) {
  1718.       chaine[i]=' ';
  1719.     }
  1720.   }
  1721. }
  1722.  
  1723. #if SHELL_MULTITHREAD
  1724.  
  1725. static int __cdecl ExcFilter_(DWORD dwExceptCode, PEXCEPTION_POINTERS pExceptPtrs) {
  1726.   return EXCEPTION_CONTINUE_EXECUTION;
  1727. }                              
  1728.  
  1729. void __cdecl RunBackRobot(void* al_p) {
  1730.   int argc;
  1731.   char** argv;
  1732.  
  1733.   while((!inprogress) && (!termine)) Sleep(10);
  1734.   if (inprogress)
  1735.     while ((!inprogress->m_hWnd) || (termine)) Sleep(10);   // attendre formulaire
  1736.     //Sleep(100);
  1737.     
  1738.     Robot_params* al=(Robot_params*) al_p;
  1739.     argc = al->argc;
  1740.     argv = al->argv;
  1741.     /* launch the engine */
  1742.     hts_init();
  1743. #ifndef _DEBUG
  1744.     __try
  1745. #endif
  1746.     {
  1747.       HTTRACK_result = hts_main(argc,argv);
  1748.     }
  1749. #ifndef _DEBUG
  1750.     __except(ExcFilter_(GetExceptionCode(), GetExceptionInformation()))
  1751.     {
  1752.       HTTRACK_result = -100;
  1753.     }
  1754. #endif
  1755.     /* clear all vars */
  1756.     WHTT_LOCK();
  1757.     termine=1;
  1758.     WHTT_UNLOCK();
  1759.     htsthread_wait_n(1);
  1760.     hts_uninit();
  1761. }
  1762. #endif
  1763.  
  1764. // modifs RX 10/10/98: gestion des ,
  1765. CString change(char* chaine,char c) {
  1766.   int comma=1; int first=1;
  1767.   CString chaine1;
  1768.   for(int i=0;i < (int) strlen(chaine);i++) {
  1769.     switch(chaine[i]) {
  1770.     case 10: case 13: case 9: case ' ': case ',':
  1771.       comma=1; 
  1772.       break;
  1773.     default:
  1774.       if (comma) {
  1775.         if (!first) chaine1 +=' ';
  1776.         else first=0; 
  1777.         chaine1  +=c; 
  1778.         comma=0;
  1779.       }
  1780.       chaine1 += chaine[i]; 
  1781.       break;
  1782.     }
  1783.   }
  1784.   return chaine1;
  1785. }
  1786.  
  1787.  
  1788. // Lancement
  1789. void lance(void) {
  1790.   char **argv;
  1791.   int argvAlloc = 1024;
  1792.   int argc=1;
  1793.   int g=0;
  1794.   int i =0;
  1795.   
  1796.   //
  1797.   if (fp_debug) {
  1798.     fprintf(fp_debug,"Building command line\r\n");
  1799.     fflush(fp_debug);
  1800.   }
  1801.   //
  1802.   ShellOptions->LINE = "";
  1803.   ShellOptions->LINE = "-";
  1804.   if (ShellOptions->choixdeb[0]!='W')
  1805.     ShellOptions->LINE += "q";         // quiet
  1806.   
  1807.   if (ShellOptions->choixdeb[0]=='/')
  1808.     ShellOptions->LINE += "i";
  1809.   else if (ShellOptions->choixdeb[0]!='!')
  1810.     ShellOptions->LINE += ShellOptions->choixdeb;
  1811.   // option de profondeur
  1812.   if(strcmp(ShellOptions->depth,"")!=0) { 
  1813.     ShellOptions->LINE += "r";
  1814.     ShellOptions->LINE += ShellOptions->depth;
  1815.   }
  1816.   if(strcmp(ShellOptions->extdepth,"")!=0) { 
  1817.     ShellOptions->LINE += "%e";
  1818.     ShellOptions->LINE += ShellOptions->extdepth;
  1819.   }
  1820.   if(strcmp(ShellOptions->cache,"")!=0) ShellOptions->LINE += ShellOptions->cache;
  1821.   if(strcmp(ShellOptions->norecatch,"")!=0) ShellOptions->LINE += ShellOptions->norecatch;
  1822.   if(strcmp(ShellOptions->testall,"")!=0) ShellOptions->LINE += ShellOptions->testall;
  1823.   if(strcmp(ShellOptions->parseall,"")!=0) ShellOptions->LINE += ShellOptions->parseall;
  1824.   if(strcmp(ShellOptions->link,"")!=0) ShellOptions->LINE += ShellOptions->link;
  1825.   if(strcmp(ShellOptions->external,"")!=0) ShellOptions->LINE += ShellOptions->external;
  1826.   if(strcmp(ShellOptions->nopurge,"")!=0) ShellOptions->LINE += ShellOptions->nopurge;
  1827.   if(strcmp(ShellOptions->hidepwd,"")!=0) ShellOptions->LINE += ShellOptions->hidepwd;
  1828.   if(strcmp(ShellOptions->hidequery,"")!=0) ShellOptions->LINE += ShellOptions->hidequery;
  1829.   if(strcmp(ShellOptions->robots,"")!=0) ShellOptions->LINE += ShellOptions->robots;
  1830.   if(strcmp(ShellOptions->cookies,"")!=0) ShellOptions->LINE += ShellOptions->cookies;
  1831.   if(strcmp(ShellOptions->checktype,"")!=0) ShellOptions->LINE += ShellOptions->checktype;
  1832.   if(strcmp(ShellOptions->parsejava,"")!=0) ShellOptions->LINE += ShellOptions->parsejava;
  1833.   if(strcmp(ShellOptions->Cache2,"")!=0) ShellOptions->LINE += ShellOptions->Cache2;
  1834.   if(strcmp(ShellOptions->logtype,"")!=0) ShellOptions->LINE += ShellOptions->logtype;
  1835.   if (ShellOptions->http10.GetLength()) ShellOptions->LINE += ShellOptions->http10;
  1836.   if (ShellOptions->toler.GetLength()) ShellOptions->LINE += ShellOptions->toler;
  1837.   if (ShellOptions->updhack.GetLength()) ShellOptions->LINE += ShellOptions->updhack;
  1838.   if (ShellOptions->urlhack.GetLength()) ShellOptions->LINE += ShellOptions->urlhack;
  1839.   
  1840.   // si get, ne pas faire
  1841.   if (strcmp(ShellOptions->choixdeb,"g")!=0) {
  1842.     if(ShellOptions->build[0]=='-') {
  1843.       ShellOptions->LINE += " ";
  1844.       ShellOptions->LINE += ShellOptions->build;
  1845.       ShellOptions->LINE += " -";
  1846.     } else if (strcmp(ShellOptions->build,"")!=0) ShellOptions->LINE += ShellOptions->build;
  1847.   }
  1848.   ShellOptions->LINE += ShellOptions->dos;
  1849.   ShellOptions->LINE += ShellOptions->index;
  1850.   ShellOptions->LINE += ShellOptions->index2;
  1851.   ShellOptions->LINE += ShellOptions->htmlfirst;
  1852.   ShellOptions->LINE += ShellOptions->filtre;
  1853.   ShellOptions->LINE += ShellOptions->max;
  1854.   ShellOptions->LINE += ShellOptions->frag;
  1855.   ShellOptions->LINE += ShellOptions->maxfile;
  1856.   ShellOptions->LINE += ShellOptions->conn;
  1857.   ShellOptions->LINE += ShellOptions->time;
  1858.   ShellOptions->LINE += ShellOptions->rate;
  1859.   ShellOptions->LINE += ShellOptions->retry;
  1860.   ShellOptions->LINE += ShellOptions->hostquit;
  1861.   ShellOptions->LINE += ShellOptions->ka;
  1862.   ShellOptions->LINE += ShellOptions->log;
  1863.   ShellOptions->LINE += ShellOptions->errpage;
  1864.   //-->
  1865.   ShellOptions->LINE += ShellOptions->waittime;
  1866.   ShellOptions->LINE += ShellOptions->maxtime;
  1867.   ShellOptions->LINE += ShellOptions->maxrate;
  1868.   ShellOptions->LINE += ShellOptions->maxconn;
  1869.   ShellOptions->LINE += ShellOptions->maxlinks;
  1870.   ShellOptions->LINE += ShellOptions->proxyftp;  
  1871.   ShellOptions->LINE += "#f";  // flush
  1872.   
  1873.   if (strcmp(ShellOptions->user,"")!=0) {ShellOptions->LINE += " ";ShellOptions->LINE += "-F";ShellOptions->LINE += " ";ShellOptions->LINE += ShellOptions->user;}
  1874.   if (strcmp(ShellOptions->footer,"")!=0) {ShellOptions->LINE += " ";ShellOptions->LINE += "-%F";ShellOptions->LINE += " ";ShellOptions->LINE += ShellOptions->footer;}
  1875.   
  1876.   if ((int)ShellOptions->proxy.GetLength()>0) {
  1877.     ShellOptions->LINE += " -P ";
  1878.     ShellOptions->LINE += ShellOptions->proxy;
  1879.     ShellOptions->LINE += ":";
  1880.     ShellOptions->LINE += ShellOptions->port;
  1881.   }
  1882.   
  1883.   if (strnotempty(LANGUAGE_ISO)) {
  1884.     ShellOptions->LINE += " -%l \"";
  1885.     ShellOptions->LINE += LANGUAGE_ISO;
  1886.     if (LANGUAGE_ISO != "en")
  1887.       ShellOptions->LINE += ", en";
  1888.     ShellOptions->LINE += ", *\"";
  1889.   }
  1890.   
  1891.   // mode spider, mettre aprΦs options
  1892.   if (ShellOptions->choixdeb[0]=='!') {
  1893.     ShellOptions->LINE += " --testlinks";
  1894.   } else if (ShellOptions->choixdeb[0]=='Y') {
  1895.     ShellOptions->LINE += " --mirrorlinks";
  1896.   }
  1897.   
  1898.   // URLs!!
  1899.   ShellOptions->LINE += " ";
  1900.   ShellOptions->LINE += ShellOptions->url;
  1901.   
  1902.   // file list
  1903.   if ((int) ShellOptions->filelist.GetLength()>0) {
  1904.     ShellOptions->LINE += " -%L \"";
  1905.     ShellOptions->LINE += ShellOptions->filelist;
  1906.     ShellOptions->LINE += "\"";
  1907.   }
  1908.   
  1909.   // chemins
  1910.   if(ShellOptions->path != "") {
  1911.     ShellOptions->LINE += " ";
  1912.     ShellOptions->LINE += "-O1";
  1913.     ShellOptions->LINE += " ";
  1914.     ShellOptions->LINE += ShellOptions->path;
  1915.   }
  1916.   
  1917.   // buffer -> les + et -
  1918.   if(strcmp(ShellOptions->buff_filtres,"")!=0) {
  1919.     //if(strcmp(diafiltre.m_url2 ,"")!=0) {
  1920.     ShellOptions->LINE += " ";
  1921.     ShellOptions->LINE += ShellOptions->buff_filtres ;
  1922.   }
  1923.   
  1924.   // --assume
  1925.   if (strnotempty(ShellOptions->buff_MIME)) {
  1926.     ShellOptions->LINE += " ";
  1927.     ShellOptions->LINE += ShellOptions->buff_MIME ;
  1928.   }
  1929.   
  1930.   // ---
  1931.   
  1932.   //
  1933.   if (fp_debug) {
  1934.     fprintf(fp_debug,"Cleaning up command line and counting parameters\r\n");
  1935.     fflush(fp_debug);
  1936.   }
  1937.   //
  1938.   // Θpurer cr,lf,tab - double espace -> espace
  1939.   {
  1940.     char *a;
  1941.     while(a=strchr(ShellOptions->LINE,9)) *a=' ';
  1942.     while(a=strchr(ShellOptions->LINE,10)) *a=' ';
  1943.     while(a=strchr(ShellOptions->LINE,13)) *a=' ';
  1944.   }
  1945.   
  1946.   ShellOptions->LINE_back = ShellOptions->LINE;
  1947.   
  1948.   // couper en morceaux
  1949.   {
  1950.     char* p=ShellOptions->LINE.GetBuffer(0);
  1951.     argv = (char**) malloct(argvAlloc * sizeof(char*));
  1952.     argv[0]="winhttrack";
  1953.     do {
  1954.       if (argc >= argvAlloc) {
  1955.         argvAlloc *= 2;
  1956.         argv = (char**) realloct(argv, argvAlloc * sizeof(char*));
  1957.         assertf(argv != NULL);
  1958.       }
  1959.       argv[argc++]=p;
  1960.       p=next_token(p,0);    // prochain token
  1961.       if (p) {
  1962.         *p=0;    // octet nul (tableau)
  1963.         p++;
  1964.       }            
  1965.     } while(p!=NULL);
  1966.   }
  1967.   
  1968.   //
  1969.   if (fp_debug) {
  1970.     fprintf(fp_debug,"Checking doit.log\r\n");
  1971.     fflush(fp_debug);
  1972.   }
  1973.   //
  1974.   // Ok, on lance!
  1975.   if(!termine) {
  1976.     int result=0;
  1977.     {
  1978.       char path_log[HTS_URLMAXSIZE*2];
  1979.       strcpybuff(path_log,CShellApp_app->end_path_complete);
  1980.       if (strlen(path_log)>0)
  1981.         if ((path_log[strlen(path_log)-1]!='/') && (path_log[strlen(path_log)-1]!='\\'))
  1982.           strcatbuff(path_log,"/");
  1983.         
  1984.         // on efface le doit.log, pour annuler les parametres anciens et en redΘfinir de nouveaux
  1985.         // c'est ici une logique qui diffΦre de la version en ligne de commande
  1986.         if (fexist(fconcat(path_log,"hts-cache/new.zip"))
  1987.           || fexist(fconcat(path_log,"hts-cache/new.ndx"))
  1988.           ) {    // un cache est prΘsent
  1989.           if (fexist(fconcat(path_log,"hts-cache/doit.log")))
  1990.             remove(fconcat(path_log,"hts-cache/doit.log"));
  1991.           FILE* fp=fopen(fconcat(path_log,"hts-cache/doit.log"),"wb");
  1992.           if (fp) fclose(fp);
  1993.         }
  1994.         //}
  1995.     }
  1996.     
  1997.     
  1998.     // ---
  1999.     // LANCER LE MIROIR
  2000.     // ---
  2001.     //
  2002.     if (fp_debug) {
  2003.       fprintf(fp_debug,"Ready to call httrack engine, launching threads\r\n");
  2004.       fflush(fp_debug);
  2005.     }
  2006.     //
  2007. #if SHELL_MULTITHREAD
  2008.     Robot_params al;
  2009.     al.argc=argc;
  2010.     al.argv=argv;
  2011.     (void)hts_newthread( RunBackRobot     , 0, (void*) &al);
  2012.     //_beginthread( RunBackRobot     , 0, (void*) &al);
  2013.     //_beginthread( RefreshBackRobot , 0, NULL);
  2014.     
  2015.     //
  2016.     if (fp_debug) {
  2017.       fprintf(fp_debug,"Threads launched, displaying main dialog\r\n");
  2018.       fflush(fp_debug);
  2019.     }
  2020.     //
  2021.     // domodal du refresh
  2022.     /* XXC A SUPPRIMER */
  2023.     while(!termine) {
  2024.       Sleep(100);
  2025.     }
  2026.     //inprogress->DoModal();
  2027.     WHTT_LOCK();
  2028.     shell_terminated=1;
  2029.     result=HTTRACK_result;
  2030.     termine=1;  
  2031.     WHTT_UNLOCK();
  2032.     //
  2033.     if (fp_debug) {
  2034.       fprintf(fp_debug,"Main dialog exited\r\n");
  2035.       fflush(fp_debug);
  2036.     }
  2037.     //
  2038.     
  2039.     // non multithread
  2040. #else
  2041. #error "Non supportΘ"
  2042. #endif
  2043.  
  2044.     /* Aborted mirror or finished? */
  2045.     {
  2046.       char path_log[HTS_URLMAXSIZE*2];
  2047.       strcpybuff(path_log,CShellApp_app->end_path_complete);
  2048.       if (strlen(path_log)>0)
  2049.         if ((path_log[strlen(path_log)-1]!='/') && (path_log[strlen(path_log)-1]!='\\'))
  2050.           strcatbuff(path_log,"/");
  2051.         if (soft_term_requested || termine_requested) {
  2052.           FILE* fp=fopen(fconcat(path_log,"hts-cache/interrupted.lock"),"wb");
  2053.           if (fp)
  2054.             fclose(fp);
  2055.         } else
  2056.           remove(fconcat(path_log,"hts-cache/interrupted.lock"));
  2057.     }
  2058.     
  2059.     //SetForegroundWindow();   // yop en premier plan!
  2060.     //
  2061.     if (fp_debug) {
  2062.       fprintf(fp_debug,"Displaying end dialog\r\n");
  2063.       fflush(fp_debug);
  2064.     }
  2065.     //
  2066.     /* New pannel */
  2067.     if (result) {      // erreur?
  2068.       strcpybuff(end_mirror_msg,LANG(LANG_F19 /*"A problem occured during the mirror\n  \"","Un problΦme est survenu pendant le miroir\n  \""*/));
  2069.       strcatbuff(end_mirror_msg,"\"");
  2070.       if (result != -100) {
  2071.         strcatbuff(end_mirror_msg,hts_errmsg());
  2072.       } else {
  2073.                 strcatbuff(end_mirror_msg, "The engine unexpectedly crashed.");
  2074.       }
  2075.       strcatbuff(end_mirror_msg,"\"");
  2076.       strcatbuff(end_mirror_msg,LANG(LANG_F20 /*"\" \nDuring:\n  ","\" \nDurant:\n  "*/));
  2077.       strcatbuff(end_mirror_msg,"\"");
  2078.       strcatbuff(end_mirror_msg,ShellOptions->LINE_back);
  2079.       strcatbuff(end_mirror_msg,"\"");
  2080.       strcatbuff(end_mirror_msg,LANG(LANG_F21 /*"\nSee the log file if necessary.\n\nClick OK to quit WinHTTrack.\n\nThanks for using WinHTTrack!","\nVoir le fichier log au besoin\n\nCliquez sur OK pour quitter WinHTTrack\n\nMerci d'utiliser WinHTTrack."*/));
  2081.       //AfxMessageBox(s,MB_OK+MB_ICONINFORMATION);
  2082.     } else {
  2083.       strcpybuff(end_mirror_msg,LANG(LANG_F22 /*"The mirror is finished.\nClick OK to quit WinHTTrack.\nSee log file(s) if necessary to ensure that everything is OK.\n\nThanks for using WinHTTrack!","Le miroir est terminΘ\nCliquez sur OK pour quitter WinHTTrack\nVoir au besoin les fichiers d'audit pour vΘrifier que tout s'est bien passΘ\n\nMerci d'utiliser WinHTTrack!"*/));
  2084.       //AfxMessageBox("The mirror is finished.\nClic OK to quit WinHTTrack.\nSee log file(s) if necessary to ensure that everything is OK.\n\nThanks for using WinHTTrack!",MB_OK+MB_ICONINFORMATION);
  2085.       //        ShellExecute(0,"open",,"","",);
  2086.     }
  2087. #if USE_RAS
  2088.     // erreur ras
  2089.     if (connected == -1)
  2090.       if ((int) strlen(connected_err) > 0)
  2091.         strcpybuff(end_mirror_msg,connected_err);
  2092. #endif
  2093.       {
  2094.         char pathlog[HTS_URLMAXSIZE*2];
  2095.         strcpybuff(pathlog,dialog0->GetPath());
  2096.         Ciplog form;
  2097.         if (strlen(pathlog)>0)
  2098.           if ((pathlog[strlen(pathlog)-1]!='/') && (pathlog[strlen(pathlog)-1]!='\\'))
  2099.             strcatbuff(pathlog,"/");
  2100.           // fichier log existe ou on est tΘlΘcommandΘ par un !
  2101.           if ( (fsize(fconcat(pathlog,"hts-err.txt")))>0) {
  2102.             strcatbuff(end_mirror_msg,LANG(LANG_F23 /*"\n\nTip: Click [View log file] to see warning or error messages","\n\nConseil: [Voir fichiers log] pour voir les erreurs et messages"*/));
  2103.           }
  2104.       }
  2105.       //this_Cinfoend->m_infoend = msg;
  2106.       inprogress->SendMessage(WM_USER + 4);      // avertir
  2107.       if (fp_debug) {
  2108.         fprintf(fp_debug,"DoModal end dialog, waiting\r\n");
  2109.         fflush(fp_debug);
  2110.       }
  2111.       /*
  2112.       if (info.DoModal() == IDC_NewProject) {     // relancer programme!
  2113.       // copie de onnewproject() de wid1::
  2114.       CWinApp* pApp = AfxGetApp();
  2115.       CString name = pApp->m_pszHelpFilePath;
  2116.       name=name.Left(name.GetLength()-4);
  2117.       name += ".EXE";
  2118.       ShellExecute(NULL,"open",name,"","",SW_RESTORE);    
  2119.       }
  2120.       */
  2121.       if (fp_debug) {
  2122.         fprintf(fp_debug,"Final info OK, leaving..\r\n");
  2123.         fflush(fp_debug);
  2124.       }
  2125.   }
  2126.   else {
  2127.   }
  2128.  
  2129.   if (argv != NULL)
  2130.     freet(argv);
  2131.   
  2132. }
  2133.  
  2134. // int LANG_T(int);
  2135. // char* LANG(char* english,char* francais);
  2136.  
  2137.  
  2138. /* interface lang - lang_string="stringlang0\nstringlang1\n..laststring" */
  2139. void SetCombo(CWnd* _this,int id,char* lang_string) {
  2140.   CComboBox* combo = (CComboBox*) _this->GetDlgItem(id);
  2141.   CString st=lang_string;
  2142.   st.TrimLeft(); st.TrimRight();
  2143.   if (combo) {
  2144.     st+="\n";         /* end */
  2145.     combo->ResetContent();
  2146.     while(st.GetLength()) {
  2147.       int pos=st.Find('\n');
  2148.       CString item=st.Left(pos);
  2149.       st=st.Mid(pos+1);
  2150.       item.TrimLeft(); item.TrimRight();
  2151.       if (item.GetLength())
  2152.         combo->AddString(item);
  2153.     }
  2154.   }
  2155. }
  2156.  
  2157.  
  2158. // Ecriture profiles
  2159. CString profile_code(char* from) {
  2160.   int i;
  2161.   CString result;
  2162.   for(i = 0 ; from[i] != '\0' ; i++) {
  2163.     switch(from[i]) {
  2164.     case '%': 
  2165.       result += '%';
  2166.       result += '%';
  2167.       break;
  2168.     case '=': 
  2169.       result += '%';
  2170.       result += '3';
  2171.       result += 'd';
  2172.       break;
  2173.     case 13:
  2174.       result += '%';
  2175.       result += '0';
  2176.       result += 'd';
  2177.       break;
  2178.     case 10:
  2179.       result += '%';
  2180.       result += '0';
  2181.       result += 'a';
  2182.       break;
  2183.     case 9:
  2184.       result += '%';
  2185.       result += '0';
  2186.       result += '9';
  2187.       break;
  2188.     default:
  2189.       result += from[i];
  2190.       break;
  2191.     }
  2192.   }
  2193.   return result;
  2194. }
  2195. CString profile_decode(char* from) {
  2196.   int j;
  2197.   CString result;
  2198.   for(j = 0 ; from[j] != '\0' ; ) {  // oui oui
  2199.     if (from[j]=='%') {
  2200.       if (from[j + 1] == '%') {
  2201.         result += '%';
  2202.         j+=2;
  2203.       } else {
  2204.         if (strncmp(from+j+1,"0d", 2)==0)
  2205.           result += (char) 13;
  2206.         else if (strncmp(from+j+1,"0a", 2)==0)
  2207.           result += (char) 10;
  2208.         else if (strncmp(from+j+1,"09", 2)==0)
  2209.           result += (char) 9;
  2210.         else if (strncmp(from+j+1,"3d", 2)==0)
  2211.           result += '=';
  2212.         else
  2213.           result += ' ';
  2214.         j+=3;
  2215.       }
  2216.     } else
  2217.       result += from[j++];
  2218.   }
  2219.   return result;
  2220. }
  2221. //
  2222. // Ecriture/Lecture profiles
  2223. int MyWriteProfileInt(CString path,CString dummy,CString name,int value) {
  2224.   if (path.IsEmpty()) {
  2225.     CWinApp* pApp = AfxGetApp();
  2226.     pApp->WriteProfileInt(dummy,name,value);
  2227.   } else if (path=="<mem>") {       // buffer
  2228.     tmpm.setInt(name,value);
  2229.     return 0;
  2230.   } else if (path=="<tmp>") {       // fichier temporaire commun
  2231.     if (tmpf) {
  2232.       return MyWriteProfileIntFile(tmpf,dummy,name,value);
  2233.     }
  2234.   } else {
  2235.     FILE* fp = fopen(path,"ab");
  2236.     if (fp) {
  2237.       int r=MyWriteProfileIntFile(fp,dummy,name,value);
  2238.       /*
  2239.       fprintf(fp,"%s=%d\x0d\x0a",name,value);
  2240.       */
  2241.       fclose(fp);
  2242.       return r;
  2243.     }
  2244.   }
  2245.   return 0;
  2246. }
  2247. int MyWriteProfileIntFile(FILE* fp,CString dummy,CString name,int value) {
  2248.   if (fp) {
  2249.     fprintf(fp,"%s=%d\x0d\x0a", name, value);
  2250.   }
  2251.   return 0;
  2252. }
  2253. int MyWriteProfileString(CString path,CString dummy,CString name,CString value) {
  2254.   if (path.IsEmpty()) {
  2255.     CWinApp* pApp = AfxGetApp();
  2256.     pApp->WriteProfileString(dummy, name, profile_code(value.GetBuffer(0)));
  2257.   } else if (path=="<mem>") {       // buffer
  2258.     tmpm.setString(name,value);
  2259.     return 0;
  2260.   } else if (path=="<tmp>") {       // fichier temporaire commun
  2261.     if (tmpf) {
  2262.       return MyWriteProfileStringFile(tmpf,dummy,name,value);
  2263.     }
  2264.   } else {
  2265.     FILE* fp = fopen(path,"ab");
  2266.     if (fp) {
  2267.       int r=MyWriteProfileStringFile(fp,dummy,name,value);
  2268.       fclose(fp);
  2269.       return r;
  2270.     }
  2271.   }
  2272.   return 0;
  2273. }
  2274. int MyWriteProfileStringFile(FILE* fp,CString dummy,CString name,CString value) {
  2275.   if (fp) {
  2276.     fprintf(fp,"%s=%s\x0d\x0a", name, profile_code(value.GetBuffer(0)).GetBuffer(0));
  2277.   }
  2278.   return 0;
  2279. }
  2280. //
  2281. // lecture
  2282. int MyGetProfileInt(CString path,CString dummy,CString name,int value) {
  2283.   if (path.IsEmpty()) {
  2284.     CWinApp* pApp = AfxGetApp();
  2285.     return pApp->GetProfileInt(dummy, name, value);
  2286.   } else if (path=="<mem>") {       // buffer
  2287.     return tmpm.getInt(name,value);
  2288.   } else if (path=="<tmp>") {       // fichier temporaire commun
  2289.     if (tmpf) {
  2290.       return MyGetProfileIntFile(tmpf,dummy,name,value);
  2291.     } else return value;
  2292.   } else {
  2293.     FILE* fp = fopen(path,"rb");
  2294.     if (fp) {
  2295.       int r=MyGetProfileIntFile(fp,dummy,name,value);
  2296.       fclose(fp);
  2297.       return r;
  2298.     } else return value;
  2299.   }
  2300. }
  2301. int MyGetProfileIntFile(FILE* fp,CString dummy,CString name,int value) {
  2302.   if (fp) {
  2303.     char srch[256];
  2304.     fseek(fp,0,SEEK_SET);
  2305.     sprintf(srch,"%s=",name);
  2306.     while(!feof(fp)) {
  2307.       char s[2048]; s[0]='\0';
  2308.       linput(fp,s,2000);
  2309.       if (strlen(s)==0)     // EOF
  2310.         return value;
  2311.       if (strncmp(s,srch,strlen(srch)) == 0) {    // ligne reconnue
  2312.         int val;
  2313.         if (sscanf(s+strlen(srch),"%d",&val) == 1)
  2314.           return val;
  2315.         else
  2316.           return value;
  2317.       }
  2318.     }
  2319.     return value;
  2320.   } else return value;
  2321. }
  2322. CString MyGetProfileString(CString path,CString dummy,CString name,CString value) {
  2323.   if (path.IsEmpty()) {
  2324.     CWinApp* pApp = AfxGetApp();
  2325.     return profile_decode(pApp->GetProfileString(dummy, name, profile_code(value.GetBuffer(0)).GetBuffer(0)).GetBuffer(0));
  2326.   } else if (path=="<mem>") {       // buffer
  2327.     return tmpm.getString(name,value);
  2328.   } else if (path=="<tmp>") {       // fichier temporaire commun
  2329.     if (tmpf) {
  2330.       return MyGetProfileStringFile(tmpf,dummy,name,value);
  2331.     } else return value;
  2332.   } else {
  2333.     FILE* fp = fopen(path,"rb");
  2334.     if (fp) {
  2335.       CString st=MyGetProfileStringFile(fp,dummy,name,value);
  2336.       fclose(fp);
  2337.       return st;
  2338.     } else return value;
  2339.   }
  2340. }
  2341. CString MyGetProfileStringFile(FILE* fp,CString dummy,CString name,CString value) {
  2342.   if (fp) {
  2343.     char srch[256];
  2344.     fseek(fp,0,SEEK_SET);
  2345.     sprintf(srch,"%s",name);
  2346.     strcatbuff(srch,"=");
  2347.     while(!feof(fp)) {
  2348.       char s[32768]; s[0]='\0';
  2349.       linput(fp,s,32000);
  2350.       if (strlen(s)==0)     // EOF
  2351.         return value;
  2352.       if (strncmp(s,srch,strlen(srch)) == 0) {    // ligne reconnue
  2353.         return profile_decode(s+strlen(srch));
  2354.       }
  2355.     }
  2356.     return value;
  2357.   } else return value;
  2358. }
  2359.  
  2360. //
  2361. // Get_profile et Write_profile eux mΩmes
  2362. //
  2363. // path="" -> Θcrire dans la base (default)
  2364. // path="<tmp>" -> Θcrire dans le fichier tempo commun
  2365. // path="<mem>" -> Θcrire dans le buffer tempo commun
  2366. // path="<null>" -> lire default (illΘgal en Θcriture)
  2367. void Write_profile(CString path,int load_path) {
  2368.   CWaitCursor wait;
  2369.   CString strSection       = "OptionsValues";
  2370.   CString st;
  2371.   int n;
  2372.   
  2373.   // Fichier tempo ou fichier?
  2374.   if (path=="<tmp>") {     // fichier temporaire
  2375.     if (tmpf)
  2376.       fclose(tmpf);
  2377.     tmpf=tmpfile();
  2378.     if (!tmpf)
  2379.       return;
  2380.   } else if (path=="<mem>") {     // buffer temporaire
  2381.     tmpm.deleteAll();
  2382.   } else if (!(path.IsEmpty())) {
  2383.     FILE *fp=fopen(path,"wb");
  2384.     if (fp) 
  2385.       fclose(fp);
  2386.   }
  2387.   
  2388.   //if (dialog3.m_hWnd == NULL) {    // pas initialisΘ
  2389.   if (maintab->m_hWnd == NULL) {    // pas initialisΘ
  2390.     // checkboxes
  2391.     MyWriteProfileInt(path,strSection, "Near",maintab->m_option1.m_link);
  2392.     MyWriteProfileInt(path,strSection, "Test",maintab->m_option1.m_testall);
  2393.     MyWriteProfileInt(path,strSection, "ParseAll",maintab->m_option1.m_parseall);
  2394.     MyWriteProfileInt(path,strSection, "HTMLFirst",maintab->m_option1.m_htmlfirst);
  2395.     MyWriteProfileInt(path,strSection, "Cache",maintab->m_option3.m_cache);
  2396.     MyWriteProfileInt(path,strSection, "NoRecatch",maintab->m_option9.m_norecatch);
  2397.     MyWriteProfileInt(path,strSection, "Dos",
  2398.       ((maintab->m_option2.m_dos)?1:0)
  2399.       +
  2400.       (((maintab->m_option2.m_iso9660)?1:0)<<1)
  2401.       );
  2402.     MyWriteProfileInt(path,strSection, "Index",maintab->m_option9.m_index);
  2403.     MyWriteProfileInt(path,strSection, "WordIndex",maintab->m_option9.m_index2);
  2404.     MyWriteProfileInt(path,strSection, "Log",maintab->m_option9.m_logf);
  2405.     MyWriteProfileInt(path,strSection, "RemoveTimeout",maintab->m_option4.m_remt);
  2406.     MyWriteProfileInt(path,strSection, "RemoveRateout",maintab->m_option4.m_rems);
  2407.     MyWriteProfileInt(path,strSection, "KeepAlive",maintab->m_option4.m_ka);
  2408.     MyWriteProfileInt(path,strSection, "FollowRobotsTxt",maintab->m_option8.m_robots);
  2409.     MyWriteProfileInt(path,strSection, "NoErrorPages",maintab->m_option2.m_errpage);
  2410.     MyWriteProfileInt(path,strSection, "NoExternalPages",maintab->m_option2.m_external);
  2411.     MyWriteProfileInt(path,strSection, "NoPwdInPages",maintab->m_option2.m_hidepwd);
  2412.     MyWriteProfileInt(path,strSection, "NoQueryStrings",maintab->m_option2.m_hidequery);
  2413.     MyWriteProfileInt(path,strSection, "NoPurgeOldFiles",maintab->m_option2.m_nopurge);
  2414.     MyWriteProfileInt(path,strSection, "Cookies",maintab->m_option8.m_cookies);
  2415.     MyWriteProfileInt(path,strSection, "CheckType",maintab->m_option8.m_checktype);
  2416.     MyWriteProfileInt(path,strSection, "ParseJava",maintab->m_option8.m_parsejava);
  2417.     MyWriteProfileInt(path,strSection, "HTTP10",maintab->m_option8.m_http10);
  2418.     MyWriteProfileInt(path,strSection, "TolerantRequests",maintab->m_option8.m_toler);
  2419.     MyWriteProfileInt(path,strSection, "UpdateHack",maintab->m_option8.m_updhack);
  2420.     MyWriteProfileInt(path,strSection, "URLHack",maintab->m_option8.m_urlhack);
  2421.     MyWriteProfileInt(path,strSection, "StoreAllInCache",maintab->m_option9.m_Cache2);
  2422.     MyWriteProfileInt(path,strSection, "LogType",maintab->m_option9.m_logtype);
  2423.     MyWriteProfileInt(path,strSection, "UseHTTPProxyForFTP",maintab->m_option10.m_ftpprox);
  2424.     
  2425.     // menus
  2426.     MyWriteProfileInt(path,strSection, "Build",maintab->m_option2.m_build);
  2427.     MyWriteProfileInt(path,strSection, "PrimaryScan",maintab->m_option3.m_filter);
  2428.     MyWriteProfileInt(path,strSection, "Travel",maintab->m_option3.m_travel);
  2429.     MyWriteProfileInt(path,strSection, "GlobalTravel",maintab->m_option3.m_travel2);
  2430.     MyWriteProfileInt(path,strSection, "RewriteLinks",maintab->m_option3.m_travel3);
  2431.     MyWriteProfileString(path,strSection, "BuildString",maintab->m_option2.Bopt.m_BuildString);
  2432.     
  2433.     // champs
  2434.     MyWriteProfileString(path,strSection, "Category", this_CSplitterFrame->GetCurrentCategory());
  2435.  
  2436.     MyWriteProfileString(path,strSection, "MaxHtml",maintab->m_option5.m_maxhtml);
  2437.     MyWriteProfileString(path,strSection, "MaxOther",maintab->m_option5.m_othermax);
  2438.     MyWriteProfileString(path,strSection, "MaxAll",maintab->m_option5.m_sizemax);
  2439.     MyWriteProfileString(path,strSection, "MaxWait",maintab->m_option5.m_pausebytes);
  2440.     MyWriteProfileString(path,strSection, "Sockets",maintab->m_option4.m_connexion);
  2441.     MyWriteProfileString(path,strSection, "Retry",maintab->m_option4.m_retry);
  2442.     MyWriteProfileString(path,strSection, "MaxTime",maintab->m_option5.m_maxtime);
  2443.     MyWriteProfileString(path,strSection, "TimeOut",maintab->m_option4.m_timeout);
  2444.     MyWriteProfileString(path,strSection, "RateOut",maintab->m_option4.m_rate);
  2445.     MyWriteProfileString(path,strSection, "UserID",maintab->m_option6.m_user);
  2446.     MyWriteProfileString(path,strSection, "Footer",maintab->m_option6.m_footer);
  2447.     MyWriteProfileString(path,strSection, "MaxRate",maintab->m_option5.m_maxrate);
  2448.     MyWriteProfileString(path,strSection, "WildCardFilters",maintab->m_option7.m_url2);
  2449.     MyWriteProfileString(path,strSection, "Proxy",maintab->m_option10.m_proxy);
  2450.     MyWriteProfileString(path,strSection, "Port",maintab->m_option10.m_port);
  2451.     MyWriteProfileString(path,strSection, "Depth",maintab->m_option5.m_depth);
  2452.     MyWriteProfileString(path,strSection, "ExtDepth",maintab->m_option5.m_depth2);
  2453.     MyWriteProfileString(path,strSection, "MaxConn",maintab->m_option5.m_maxconn);    
  2454.     MyWriteProfileString(path,strSection, "MaxLinks",maintab->m_option5.m_maxlinks);    
  2455.     
  2456.     // 11
  2457.     MyWriteProfileString(path,strSection, "MIMEDefsExt1",maintab->m_option11.m_ext1);    
  2458.     MyWriteProfileString(path,strSection, "MIMEDefsExt2",maintab->m_option11.m_ext2);    
  2459.     MyWriteProfileString(path,strSection, "MIMEDefsExt3",maintab->m_option11.m_ext3);    
  2460.     MyWriteProfileString(path,strSection, "MIMEDefsExt4",maintab->m_option11.m_ext4);    
  2461.     MyWriteProfileString(path,strSection, "MIMEDefsExt5",maintab->m_option11.m_ext5);    
  2462.     MyWriteProfileString(path,strSection, "MIMEDefsExt6",maintab->m_option11.m_ext6);    
  2463.     MyWriteProfileString(path,strSection, "MIMEDefsExt7",maintab->m_option11.m_ext7);    
  2464.     MyWriteProfileString(path,strSection, "MIMEDefsExt8",maintab->m_option11.m_ext8);    
  2465.     MyWriteProfileString(path,strSection, "MIMEDefsMime1",maintab->m_option11.m_mime1);    
  2466.     MyWriteProfileString(path,strSection, "MIMEDefsMime2",maintab->m_option11.m_mime2);    
  2467.     MyWriteProfileString(path,strSection, "MIMEDefsMime3",maintab->m_option11.m_mime3);    
  2468.     MyWriteProfileString(path,strSection, "MIMEDefsMime4",maintab->m_option11.m_mime4);    
  2469.     MyWriteProfileString(path,strSection, "MIMEDefsMime5",maintab->m_option11.m_mime5);    
  2470.     MyWriteProfileString(path,strSection, "MIMEDefsMime6",maintab->m_option11.m_mime6);    
  2471.     MyWriteProfileString(path,strSection, "MIMEDefsMime7",maintab->m_option11.m_mime7);    
  2472.     MyWriteProfileString(path,strSection, "MIMEDefsMime8",maintab->m_option11.m_mime8);
  2473.   } else {
  2474.     st = this_CSplitterFrame->GetCurrentCategory(); MyWriteProfileString(path,strSection,"Category",st);
  2475.  
  2476.     // checkboxes
  2477.     // 1
  2478.     n=maintab->m_option1.IsDlgButtonChecked(IDC_link);
  2479.     MyWriteProfileInt(path,strSection,"Near", n);
  2480.     n=maintab->m_option1.IsDlgButtonChecked(IDC_testall);
  2481.     MyWriteProfileInt(path,strSection,"Test", n);
  2482.     n=maintab->m_option1.IsDlgButtonChecked(IDC_parseall);
  2483.     MyWriteProfileInt(path,strSection,"ParseAll", n);
  2484.     n=maintab->m_option1.IsDlgButtonChecked(IDC_htmlfirst);
  2485.     MyWriteProfileInt(path,strSection,"HTMLFirst", n);
  2486.     // 2
  2487.     n=maintab->m_option3.IsDlgButtonChecked(IDC_Cache);
  2488.     MyWriteProfileInt(path,strSection,"Cache", n);
  2489.     n=maintab->m_option2.IsDlgButtonChecked(IDC_norecatch);
  2490.     MyWriteProfileInt(path,strSection,"NoRecatch", n);
  2491.     n = ((maintab->m_option2.IsDlgButtonChecked(IDC_dos))?1:0)
  2492.       + ((maintab->m_option2.IsDlgButtonChecked(IDC_iso9660)?1:0)<<1);
  2493.     MyWriteProfileInt(path,strSection,"Dos", n);
  2494.     n=maintab->m_option2.IsDlgButtonChecked(IDC_index);
  2495.     MyWriteProfileInt(path,strSection,"Index", n);
  2496.     n=maintab->m_option2.IsDlgButtonChecked(IDC_index2);
  2497.     MyWriteProfileInt(path,strSection,"WordIndex", n);
  2498.     n=maintab->m_option2.IsDlgButtonChecked(IDC_logf);
  2499.     MyWriteProfileInt(path,strSection,"Log", n);
  2500.     n=maintab->m_option2.IsDlgButtonChecked(IDC_errpage);
  2501.     MyWriteProfileInt(path,strSection,"NoErrorPages", n);
  2502.     n=maintab->m_option2.IsDlgButtonChecked(IDC_hidepwd);
  2503.     MyWriteProfileInt(path,strSection,"NoPwdInPages", n);
  2504.     n=maintab->m_option2.IsDlgButtonChecked(IDC_hidequery);
  2505.     MyWriteProfileInt(path,strSection,"NoQueryStrings", n);
  2506.     n=maintab->m_option2.IsDlgButtonChecked(IDC_external);
  2507.     MyWriteProfileInt(path,strSection,"NoExternalPages", n);
  2508.     n=maintab->m_option2.IsDlgButtonChecked(IDC_nopurge);
  2509.     MyWriteProfileInt(path,strSection,"NoPurgeOldFiles", n);
  2510.     if ((n=maintab->m_option2.m_ctl_build.GetCurSel()) != CB_ERR)
  2511.       MyWriteProfileInt(path,strSection, "Build", n);
  2512.     st = maintab->m_option2.Bopt.m_BuildString;
  2513.     if (st.GetLength()>0)
  2514.       MyWriteProfileString(path,strSection, "BuildString",st);
  2515.     // 3
  2516.     // menus
  2517.     if ((n=maintab->m_option3.m_ctl_filter.GetCurSel()) != CB_ERR)
  2518.       MyWriteProfileInt(path,strSection, "PrimaryScan", n);
  2519.     if ((n=maintab->m_option3.m_ctl_travel.GetCurSel()) != CB_ERR)
  2520.       MyWriteProfileInt(path,strSection, "Travel", n);
  2521.     if ((n=maintab->m_option3.m_ctl_travel2.GetCurSel()) != CB_ERR)
  2522.       MyWriteProfileInt(path,strSection, "GlobalTravel", n);
  2523.     if ((n=maintab->m_option3.m_ctl_travel3.GetCurSel()) != CB_ERR)
  2524.       MyWriteProfileInt(path,strSection, "RewriteLinks", n);
  2525.     //
  2526.     maintab->m_option8.GetDlgItemText(IDC_robots,st);
  2527.     MyWriteProfileString(path,strSection, "FollowRobotsTxt", st);
  2528.     // 4
  2529.     maintab->m_option4.GetDlgItemText(IDC_connexion,st);
  2530.     MyWriteProfileString(path,strSection, "Sockets", st);
  2531.     maintab->m_option4.GetDlgItemText(IDC_timeout,st);
  2532.     MyWriteProfileString(path,strSection, "TimeOut", st);
  2533.     n=maintab->m_option4.IsDlgButtonChecked(IDC_remt);
  2534.     MyWriteProfileInt(path,strSection,"RemoveTimeout", n);
  2535.     maintab->m_option4.GetDlgItemText(IDC_retry,st);
  2536.     MyWriteProfileString(path,strSection, "Retry", st);
  2537.     maintab->m_option4.GetDlgItemText(IDC_rate,st);
  2538.     MyWriteProfileString(path,strSection, "RateOut", st);
  2539.     n=maintab->m_option4.IsDlgButtonChecked(IDC_rems);
  2540.     MyWriteProfileInt(path,strSection,"RemoveRateout", n);
  2541.     n=maintab->m_option4.IsDlgButtonChecked(IDC_ka);
  2542.     MyWriteProfileInt(path,strSection,"KeepAlive", n);
  2543.     // 5
  2544.     maintab->m_option5.GetDlgItemText(IDC_maxhtml,st);
  2545.     MyWriteProfileString(path,strSection, "MaxHtml", st);
  2546.     maintab->m_option5.GetDlgItemText(IDC_othermax,st);
  2547.     MyWriteProfileString(path,strSection, "MaxOther", st);
  2548.     maintab->m_option5.GetDlgItemText(IDC_sizemax,st);
  2549.     MyWriteProfileString(path,strSection, "MaxAll", st);
  2550.     maintab->m_option5.GetDlgItemText(IDC_pausebytes,st);
  2551.     MyWriteProfileString(path,strSection, "MaxWait", st);
  2552.     maintab->m_option5.GetDlgItemText(IDC_maxtime,st);
  2553.     MyWriteProfileString(path,strSection, "MaxTime", st);
  2554.     maintab->m_option5.GetDlgItemText(IDC_maxrate,st);
  2555.     MyWriteProfileString(path,strSection, "MaxRate", st);
  2556.     maintab->m_option5.GetDlgItemText(IDC_depth,st);
  2557.     MyWriteProfileString(path,strSection,"Depth",st);
  2558.     maintab->m_option5.GetDlgItemText(IDC_depth2,st);
  2559.     MyWriteProfileString(path,strSection,"ExtDepth",st);
  2560.     maintab->m_option5.GetDlgItemText(IDC_maxconn,st);
  2561.     MyWriteProfileString(path,strSection, "MaxConn", st);
  2562.     maintab->m_option5.GetDlgItemText(IDC_maxlinks,st);
  2563.     MyWriteProfileString(path,strSection, "MaxLinks", st);
  2564.     // 6
  2565.     maintab->m_option6.GetDlgItemText(IDC_user,st);
  2566.     MyWriteProfileString(path,strSection, "UserID", st);
  2567.     maintab->m_option6.GetDlgItemText(IDC_footer,st);
  2568.     MyWriteProfileString(path,strSection, "Footer", st);
  2569.     // 7
  2570.     maintab->m_option7.GetDlgItemText(IDC_URL2,st);
  2571.     MyWriteProfileString(path,strSection, "WildCardFilters", st);
  2572.     // 8
  2573.     maintab->m_option8.GetDlgItemText(IDC_cookies,st);
  2574.     MyWriteProfileString(path,strSection, "Cookies", st);
  2575.     maintab->m_option8.GetDlgItemText(IDC_checktype,st);
  2576.     MyWriteProfileString(path,strSection, "CheckType", st);
  2577.     n=maintab->m_option8.IsDlgButtonChecked(IDC_parsejava);
  2578.     MyWriteProfileInt(path,strSection, "ParseJava", n);
  2579.     n=maintab->m_option8.IsDlgButtonChecked(IDC_http10);
  2580.     MyWriteProfileInt(path,strSection, "HTTP10", n);
  2581.     n=maintab->m_option8.IsDlgButtonChecked(IDC_toler);
  2582.     MyWriteProfileInt(path,strSection, "TolerantRequests", n);
  2583.     n=maintab->m_option8.IsDlgButtonChecked(IDC_updhack);
  2584.     MyWriteProfileInt(path,strSection, "UpdateHack", n);
  2585.     n=maintab->m_option8.IsDlgButtonChecked(IDC_urlhack);
  2586.     MyWriteProfileInt(path,strSection, "URLHack", n);
  2587.     // 9
  2588.     maintab->m_option9.GetDlgItemText(IDC_Cache2,st);
  2589.     MyWriteProfileString(path,strSection, "StoreAllInCache", st);
  2590.     maintab->m_option9.GetDlgItemText(IDC_logtype,st);
  2591.     MyWriteProfileString(path,strSection, "LogType", st);
  2592.     // 10
  2593.     maintab->m_option10.GetDlgItemText(IDC_prox,st);
  2594.     MyWriteProfileString(path,strSection,"Proxy",st);
  2595.     maintab->m_option10.GetDlgItemText(IDC_proxport,st);
  2596.     MyWriteProfileString(path,strSection,"Port",st);
  2597.     n=maintab->m_option10.IsDlgButtonChecked(IDC_ftpprox);
  2598.     MyWriteProfileInt(path,strSection,"UseHTTPProxyForFTP", n);
  2599.     
  2600.     // 11
  2601.     maintab->m_option11.GetDlgItemText(IDC_ext1,st); MyWriteProfileString(path,strSection,"MIMEDefsExt1",st);
  2602.     maintab->m_option11.GetDlgItemText(IDC_ext2,st); MyWriteProfileString(path,strSection,"MIMEDefsExt2",st);
  2603.     maintab->m_option11.GetDlgItemText(IDC_ext3,st); MyWriteProfileString(path,strSection,"MIMEDefsExt3",st);
  2604.     maintab->m_option11.GetDlgItemText(IDC_ext4,st); MyWriteProfileString(path,strSection,"MIMEDefsExt4",st);
  2605.     maintab->m_option11.GetDlgItemText(IDC_ext5,st); MyWriteProfileString(path,strSection,"MIMEDefsExt5",st);
  2606.     maintab->m_option11.GetDlgItemText(IDC_ext6,st); MyWriteProfileString(path,strSection,"MIMEDefsExt6",st);
  2607.     maintab->m_option11.GetDlgItemText(IDC_ext7,st); MyWriteProfileString(path,strSection,"MIMEDefsExt7",st);
  2608.     maintab->m_option11.GetDlgItemText(IDC_ext8,st); MyWriteProfileString(path,strSection,"MIMEDefsExt8",st);
  2609.     maintab->m_option11.GetDlgItemText(IDC_mime1,st); MyWriteProfileString(path,strSection,"MIMEDefsMime1",st);
  2610.     maintab->m_option11.GetDlgItemText(IDC_mime2,st); MyWriteProfileString(path,strSection,"MIMEDefsMime2",st);
  2611.     maintab->m_option11.GetDlgItemText(IDC_mime3,st); MyWriteProfileString(path,strSection,"MIMEDefsMime3",st);
  2612.     maintab->m_option11.GetDlgItemText(IDC_mime4,st); MyWriteProfileString(path,strSection,"MIMEDefsMime4",st);
  2613.     maintab->m_option11.GetDlgItemText(IDC_mime5,st); MyWriteProfileString(path,strSection,"MIMEDefsMime5",st);
  2614.     maintab->m_option11.GetDlgItemText(IDC_mime6,st); MyWriteProfileString(path,strSection,"MIMEDefsMime6",st);
  2615.     maintab->m_option11.GetDlgItemText(IDC_mime7,st); MyWriteProfileString(path,strSection,"MIMEDefsMime7",st);
  2616.     maintab->m_option11.GetDlgItemText(IDC_mime8,st); MyWriteProfileString(path,strSection,"MIMEDefsMime8",st);
  2617.   }
  2618.   // liens, jokers etc. si mirror merge
  2619.   if (!(path.IsEmpty())) {
  2620.     if (dialog1->m_hWnd == NULL) {    // pas initialisΘ
  2621.       //MyWriteProfileString(path,strSection,"CurrentDepth",dialog1->m_depth);
  2622.       MyWriteProfileString(path,strSection,"CurrentUrl",dialog1->m_urls);
  2623.       if (dialog1->m_todo >= 0)
  2624.         MyWriteProfileInt(path, strSection,"CurrentAction", dialog1->m_todo);
  2625.       //
  2626.       MyWriteProfileString(path,strSection,"CurrentURLList",dialog1->m_filelist);
  2627.       
  2628.       //if (load_path) {
  2629.       //MyWriteProfileString(path,strSection,"CurrentPath1",dialog0->GetPath());
  2630.       //MyWriteProfileString(path,strSection,"CurrentPath2",dialog0->GetPath());
  2631.       //}
  2632.     } else {
  2633.       //dialog1->GetDlgItemText(IDC_depth,st);
  2634.       //MyWriteProfileString(path,strSection,"CurrentDepth",st);
  2635.       dialog1->GetDlgItemText(IDC_URL,st);
  2636.       MyWriteProfileString(path,strSection,"CurrentUrl",st);
  2637.       if ((n=dialog1->m_ctl_todo.GetCurSel()) != CB_ERR)
  2638.         MyWriteProfileInt(path,strSection, "CurrentAction", n);
  2639.       //
  2640.       dialog1->GetDlgItemText(IDC_filelist,st);
  2641.       MyWriteProfileString(path,strSection,"CurrentURLList",st);
  2642.       //
  2643.       //if (load_path) {
  2644.       //dialog1->GetDlgItemText(IDC_pathlog,st);
  2645.       //MyWriteProfileString(path,strSection,"CurrentPath1",st);
  2646.       //dialog1->GetDlgItemText(IDC_pthmir,st);
  2647.       //MyWriteProfileString(path,strSection,"CurrentPath2",st);
  2648.       //}
  2649.     }
  2650.   }
  2651. }
  2652. // path="" -> lire dans la base (default)
  2653. //if not exist: do not load anything but patches projname&co
  2654. void Read_profile(CString path,int load_path) {
  2655.   CWaitCursor wait;
  2656.   CString strSection       = "OptionsValues";
  2657.   CString st;
  2658.   
  2659.   // VΘrification <tmp>
  2660.   if (path=="<tmp>") {     // fichier temporaire
  2661.     if (!tmpf)
  2662.       return;
  2663.     else
  2664.       fflush(tmpf);
  2665.   } else if (path=="<null>") {     // options par dΘfaut
  2666.     path="<mem>";
  2667.     tmpm.deleteAll();              // effacer
  2668.   } else {
  2669.     int pos=path.ReverseFind('\\');
  2670.     if (pos>=0) {
  2671.       CString dir=path.Left(pos);           // enlever winprofile.ini
  2672.       pos=dir.ReverseFind('\\');
  2673.       if (pos>=0) {
  2674.         dir=dir.Left(pos);                  // enlever hts-cache
  2675.         pos=dir.ReverseFind('\\');
  2676.         if (pos>=0) {
  2677.           dialog0->m_projname=dir.Mid(pos+1);
  2678.           dialog0->m_projpath=dir.Left(pos);
  2679.           /*
  2680.           if (this_CWizTab)
  2681.           this_CWizTab->SetActivePage(2);     // page 3
  2682.           */
  2683.         }
  2684.       }
  2685.     }
  2686.   }
  2687.   
  2688.   // checkboxes
  2689.   maintab->m_option1.m_link      = MyGetProfileInt(path,strSection, "Near",0);
  2690.   maintab->m_option1.m_testall   = MyGetProfileInt(path,strSection, "Test",0);
  2691.   maintab->m_option1.m_parseall  = MyGetProfileInt(path,strSection, "ParseAll",1);
  2692.   maintab->m_option1.m_htmlfirst = MyGetProfileInt(path,strSection, "HTMLFirst",0);
  2693.   maintab->m_option3.m_cache     = MyGetProfileInt(path,strSection, "Cache",1);
  2694.   maintab->m_option9.m_norecatch = MyGetProfileInt(path,strSection, "NoRecatch",0);
  2695.   maintab->m_option2.m_dos       = (MyGetProfileInt(path,strSection, "Dos",0) & 1);
  2696.   maintab->m_option2.m_iso9660   = ((MyGetProfileInt(path,strSection, "Dos",0) & 2)>>1);
  2697.   maintab->m_option9.m_index     = MyGetProfileInt(path,strSection, "Index",1);
  2698.   maintab->m_option9.m_index2    = MyGetProfileInt(path,strSection, "WordIndex",0);
  2699.   maintab->m_option9.m_logf      = MyGetProfileInt(path,strSection, "Log",1);
  2700.   maintab->m_option4.m_remt      = MyGetProfileInt(path,strSection, "RemoveTimeout",0);
  2701.   maintab->m_option4.m_rems      = MyGetProfileInt(path,strSection, "RemoveRateout",0);
  2702.   maintab->m_option4.m_ka        = MyGetProfileInt(path,strSection, "KeepAlive",1);
  2703.   maintab->m_option8.m_robots    = MyGetProfileInt(path,strSection, "FollowRobotsTxt",2);
  2704.   maintab->m_option2.m_errpage   = MyGetProfileInt(path,strSection, "NoErrorPages",0);
  2705.   maintab->m_option2.m_external  = MyGetProfileInt(path,strSection, "NoExternalPages",0);
  2706.   maintab->m_option2.m_hidepwd   = MyGetProfileInt(path,strSection, "NoPwdInPages",0);
  2707.   maintab->m_option2.m_hidequery = MyGetProfileInt(path,strSection, "NoQueryStrings",0);
  2708.   maintab->m_option2.m_nopurge   = MyGetProfileInt(path,strSection, "NoPurgeOldFiles",0);
  2709.   maintab->m_option8.m_cookies    = MyGetProfileInt(path,strSection, "Cookies",1);
  2710.   maintab->m_option8.m_checktype  = MyGetProfileInt(path,strSection, "CheckType",1);
  2711.   maintab->m_option8.m_parsejava  = MyGetProfileInt(path,strSection, "ParseJava",1);
  2712.   maintab->m_option8.m_toler      = MyGetProfileInt(path,strSection, "TolerantRequests",0);
  2713.   maintab->m_option8.m_updhack    = MyGetProfileInt(path,strSection, "UpdateHack",1);
  2714.   maintab->m_option8.m_urlhack    = MyGetProfileInt(path,strSection, "URLHack",1);
  2715.   maintab->m_option8.m_http10     = MyGetProfileInt(path,strSection, "HTTP10",0);
  2716.   maintab->m_option9.m_Cache2     = MyGetProfileInt(path,strSection, "StoreAllInCache",0);
  2717.   maintab->m_option9.m_logtype    = MyGetProfileInt(path,strSection, "LogType",0);
  2718.   
  2719.   // menus
  2720.   maintab->m_option2.m_build   = MyGetProfileInt(path,strSection, "Build",0);
  2721.   maintab->m_option3.m_filter  = MyGetProfileInt(path,strSection, "PrimaryScan",3);
  2722.   maintab->m_option3.m_travel  = MyGetProfileInt(path,strSection, "Travel",1);
  2723.   maintab->m_option3.m_travel2 = MyGetProfileInt(path,strSection, "GlobalTravel",0);
  2724.   maintab->m_option3.m_travel3 = MyGetProfileInt(path,strSection, "RewriteLinks",0);
  2725.   maintab->m_option2.Bopt.m_BuildString = MyGetProfileString(path,strSection, "BuildString","%h%p/%n%q.%t");
  2726.   
  2727.   // champs
  2728.   dialog0->m_projcateg =          MyGetProfileString(path,strSection, "Category");
  2729.  
  2730.   maintab->m_option5.m_maxhtml =  MyGetProfileString(path,strSection, "MaxHtml");
  2731.   maintab->m_option5.m_othermax=  MyGetProfileString(path,strSection, "MaxOther");
  2732.   maintab->m_option5.m_sizemax =  MyGetProfileString(path,strSection, "MaxAll");
  2733.   maintab->m_option5.m_pausebytes=MyGetProfileString(path,strSection, "MaxWait");  
  2734.   maintab->m_option4.m_connexion= MyGetProfileString(path,strSection, "Sockets");
  2735.   maintab->m_option4.m_retry   =  MyGetProfileString(path,strSection, "Retry");
  2736.   maintab->m_option5.m_maxtime =  MyGetProfileString(path,strSection, "MaxTime");
  2737.   maintab->m_option4.m_timeout =  MyGetProfileString(path,strSection, "TimeOut");
  2738.   maintab->m_option4.m_rate    =  MyGetProfileString(path,strSection, "RateOut");
  2739.   maintab->m_option6.m_user    =  MyGetProfileString(path,strSection, "UserID","Mozilla/4.5 (compatible; HTTrack 3.0x; Windows 98)");
  2740.   maintab->m_option6.m_footer  =  MyGetProfileString(path,strSection, "Footer",HTS_DEFAULT_FOOTER);
  2741.   maintab->m_option5.m_maxrate =  MyGetProfileString(path,strSection, "MaxRate", "25000");
  2742.   maintab->m_option5.m_maxconn =  MyGetProfileString(path,strSection, "MaxConn");
  2743.   maintab->m_option5.m_maxlinks = MyGetProfileString(path,strSection, "MaxLinks");
  2744.   
  2745.   // 7
  2746.   maintab->m_option7.m_url2 = MyGetProfileString(path,strSection, "WildCardFilters","+*.png +*.gif +*.jpg +*.css +*.js -ad.doubleclick.net/* -mime:application/foobar");
  2747.   
  2748.   // 10
  2749.   maintab->m_option10.m_proxy   = MyGetProfileString(path,strSection, "Proxy");
  2750.   maintab->m_option10.m_port    = MyGetProfileString(path,strSection, "Port");
  2751.   maintab->m_option10.m_ftpprox = MyGetProfileInt(path,strSection, "UseHTTPProxyForFTP",1);
  2752.   //
  2753.   maintab->m_option5.m_depth    = MyGetProfileString(path,strSection, "Depth");
  2754.   maintab->m_option5.m_depth2   = MyGetProfileString(path,strSection, "ExtDepth");
  2755.   
  2756.   // 11
  2757.   maintab->m_option11.m_ext1   = MyGetProfileString(path,strSection, "MIMEDefsExt1");   // php3,php,php2,asp,jsp,pl,cfm,nsf
  2758.   maintab->m_option11.m_ext2   = MyGetProfileString(path,strSection, "MIMEDefsExt2");
  2759.   maintab->m_option11.m_ext3   = MyGetProfileString(path,strSection, "MIMEDefsExt3");
  2760.   maintab->m_option11.m_ext4   = MyGetProfileString(path,strSection, "MIMEDefsExt4");
  2761.   maintab->m_option11.m_ext5   = MyGetProfileString(path,strSection, "MIMEDefsExt5");
  2762.   maintab->m_option11.m_ext6   = MyGetProfileString(path,strSection, "MIMEDefsExt6");
  2763.   maintab->m_option11.m_ext7   = MyGetProfileString(path,strSection, "MIMEDefsExt7");
  2764.   maintab->m_option11.m_ext8   = MyGetProfileString(path,strSection, "MIMEDefsExt8");
  2765.   maintab->m_option11.m_mime1   = MyGetProfileString(path,strSection, "MIMEDefsMime1");   // text/html
  2766.   maintab->m_option11.m_mime2   = MyGetProfileString(path,strSection, "MIMEDefsMime2");
  2767.   maintab->m_option11.m_mime3   = MyGetProfileString(path,strSection, "MIMEDefsMime3");
  2768.   maintab->m_option11.m_mime4   = MyGetProfileString(path,strSection, "MIMEDefsMime4");
  2769.   maintab->m_option11.m_mime5   = MyGetProfileString(path,strSection, "MIMEDefsMime5");
  2770.   maintab->m_option11.m_mime6   = MyGetProfileString(path,strSection, "MIMEDefsMime6");
  2771.   maintab->m_option11.m_mime7   = MyGetProfileString(path,strSection, "MIMEDefsMime7");
  2772.   maintab->m_option11.m_mime8   = MyGetProfileString(path,strSection, "MIMEDefsMime8");
  2773.   
  2774.   
  2775.   //st = MyGetProfileString(path,strSection,"WildCardFilters");
  2776.   //ShellOptions->buff_filtres = st;
  2777.   
  2778.   // liens, jokers etc. si mirror merge
  2779.   if (!(path.IsEmpty())) {
  2780.     if (dialog1->m_hWnd == NULL) {    // pas initialisΘ
  2781.       //dialog1->m_depth  = MyGetProfileString(path,strSection,"CurrentDepth");
  2782.       dialog1->m_urls     = MyGetProfileString(path,strSection,"CurrentUrl");
  2783.       dialog1->m_todo     = MyGetProfileInt(path,strSection,"CurrentAction",0);
  2784.       dialog1->m_filelist = MyGetProfileString(path,strSection,"CurrentURLList");
  2785.       /*
  2786.       if (load_path) {
  2787.       CString st;
  2788.       st = MyGetProfileString(path,strSection,"CurrentPath1");
  2789.       if (st != "")
  2790.       dialog1->m_pathlog = st;
  2791.       st = MyGetProfileString(path,strSection,"CurrentPath2");
  2792.       if (st != "")
  2793.       dialog1->m_pathmir = st;
  2794.       }
  2795.       */
  2796.     } else {
  2797.       //st = MyGetProfileString(path,strSection,"CurrentDepth");
  2798.       //dialog1->SetDlgItemText(IDC_depth,st);
  2799.       st = MyGetProfileString(path,strSection,"CurrentUrl");
  2800.       SetDlgItemTextCP(dialog1, IDC_URL,st);
  2801.       int n = MyGetProfileInt(path,strSection,"CurrentAction",0);
  2802.       dialog1->m_ctl_todo.SetCurSel(n);
  2803.       st = MyGetProfileString(path,strSection,"CurrentURLList");
  2804.       SetDlgItemTextCP(dialog1, IDC_filelist,st);
  2805.       /*
  2806.       if (load_path) {
  2807.       st = MyGetProfileString(path,strSection,"CurrentPath1");
  2808.       if (st != "")
  2809.       dialog1->SetDlgItemText(IDC_pathlog,st);
  2810.       st = MyGetProfileString(path,strSection,"CurrentPath2");
  2811.       if (st != "")
  2812.       dialog1->SetDlgItemText(IDC_pthmir,st);
  2813.       }
  2814.       */
  2815.       dialog1->Refresh();
  2816.     }
  2817.   }
  2818.   
  2819. }
  2820.  
  2821. // Initialisation du RAS
  2822. void InitRAS() {
  2823. #if USE_RAS
  2824.   if (!LibRas) {
  2825.     LibRas=new CDynamicRAS();
  2826.     if (LibRas->IsRASLoaded()) 
  2827.       LibRasUse=1;
  2828.     else
  2829.       LibRasUse=0;
  2830.   }
  2831. #endif
  2832. }
  2833.  
  2834. // Reconstruire index gΘnΘral!
  2835. void Build_TopIndex(BOOL check_empty) {
  2836.   CWaitCursor wait;
  2837.  
  2838.   //if (toptemplate_header && toptemplate_body && toptemplate_footer) {
  2839.   {
  2840.     char path[HTS_URLMAXSIZE*2];
  2841.     strcpybuff(path,CShellApp_app->end_path);
  2842.  
  2843.     /* Build top index */
  2844.     hts_buildtopindex(NULL,path, "");
  2845.  
  2846.     /* Check empty dirs and build .whtt */
  2847.     // FILE* fpo=fopen(fconcat(path,"/index.html"),"wb");
  2848.     //if (fpo) {
  2849.     {
  2850.       // verif_backblue(opt, path);    // gΘnΘrer gif
  2851.       //
  2852.       // Header
  2853.       //fprintf(fpo,toptemplate_header,
  2854.       //  "<!-- Mirror and index made by HTTrack Website Copier/"HTTRACK_VERSION" "HTTRACK_AFF_AUTHORS" -->"
  2855.       //  );
  2856.       // chargement de la liste
  2857.       WIN32_FIND_DATA find;
  2858.       HANDLE h = FindFirstFile(CShellApp_app->end_path+"*.*",&find);
  2859.       if (h != INVALID_HANDLE_VALUE) {
  2860.         CString to_delete="";
  2861.         do {
  2862.           if (!(find.dwFileAttributes  & (FILE_ATTRIBUTE_SYSTEM|FILE_ATTRIBUTE_HIDDEN) ))
  2863.             if (strcmp(find.cFileName,".."))
  2864.               if (strcmp(find.cFileName,"."))
  2865.                 if (find.dwFileAttributes  & FILE_ATTRIBUTE_DIRECTORY ) {
  2866.                   int r;
  2867.                   r=CheckDirInfo(CShellApp_app->end_path+find.cFileName);
  2868.                   if ((r>=0) && (r<=3)) {       /* vide, fichiers vides etc */
  2869.                     to_delete+=(CShellApp_app->end_path+find.cFileName+"\n");
  2870.                   } else {      /* non vide */
  2871.                     char iname[HTS_URLMAXSIZE*2],iname2[HTS_URLMAXSIZE*2];
  2872.                     strcpybuff(iname,CShellApp_app->end_path);
  2873.                     strcatbuff(iname,find.cFileName);
  2874.                     strcatbuff(iname,"\\");
  2875.                     strcpybuff(iname2,iname);
  2876.                     strcatbuff(iname,"index.html");
  2877.                     strcatbuff(iname2,"\\hts-cache\\winprofile.ini");
  2878.                     if (fexist(iname)) {
  2879.                       char hname[HTS_URLMAXSIZE*2];
  2880.                       strcpybuff(hname,find.cFileName);
  2881.                       escape_check_url(hname);
  2882.                       // Body
  2883.                       //fprintf(fpo,toptemplate_body,
  2884.                       //  hname,
  2885.                       //  find.cFileName
  2886.                       //  );
  2887.                     }
  2888.                     
  2889.                     if ((fexist(iname)) || (fexist(iname2)) ) {
  2890.                       // vΘrifier existence de .whtt
  2891.                       strcpybuff(iname,CShellApp_app->end_path);
  2892.                       strcatbuff(iname,find.cFileName);
  2893.                       strcatbuff(iname,".whtt");
  2894.                       if (!fexist(iname)) {
  2895.                         FILE* fp=fopen(iname,"wb");
  2896.                         if (fp) fclose(fp);
  2897.                       }
  2898.                       
  2899.                     }
  2900.                   }
  2901.                 } else {    /* effacer .whtt qui ne pointent vers rien */
  2902.                   CString iname=CShellApp_app->end_path+find.cFileName;
  2903.                   if (iname.Right(5).CompareNoCase(".whtt")==0) {
  2904.                     CString rname=iname.Left(iname.GetLength()-5)+"\\index.html";
  2905.                     CString rname2=iname.Left(iname.GetLength()-5)+"\\hts-cache\\winprofile.ini";
  2906.                     if ( (!fexist((char*)LPCTSTR(rname))) && (!fexist((char*)LPCTSTR(rname2))) ) {
  2907.                       remove(iname);
  2908.                     }
  2909.                   }
  2910.                 }
  2911.         } while(FindNextFile(h,&find));
  2912.         FindClose(h);
  2913.         if (check_empty) {
  2914.           while(to_delete.GetLength()>0) {
  2915.             int pos=to_delete.Find('\n');
  2916.             if (pos) {
  2917.               CString path=to_delete.Left(pos);
  2918.               to_delete=to_delete.Mid(pos+1);
  2919.               CString str;
  2920.               str.Format(LANG_DELETEEMPTYCONF,path);
  2921.               if (AfxMessageBox(str,MB_OKCANCEL)==IDOK) {
  2922.                 /* Θliminer au besoin le .whtt */
  2923.                 DeleteFile(path+".whtt");
  2924.                 if (!RemoveEmptyDir(path))
  2925.                   AfxMessageBox(LANG_ERRORDEL);
  2926.               }
  2927.             } else
  2928.               to_delete="";
  2929.           }
  2930.         }
  2931.       }
  2932.       // Footer
  2933.       //fprintf(fpo,toptemplate_footer,
  2934.       //  "<!-- Mirror and index made by HTTrack Website Copier/"HTTRACK_VERSION" "HTTRACK_AFF_AUTHORS" -->"
  2935.       //  );
  2936.       //fclose(fpo);
  2937.     }
  2938.     
  2939.   }
  2940.  
  2941.   /*
  2942.   if (toptemplate_header)
  2943.     freet(toptemplate_header);
  2944.   if (toptemplate_body)
  2945.     freet(toptemplate_body);
  2946.   if (toptemplate_footer)
  2947.     freet(toptemplate_footer);
  2948.   */
  2949. }
  2950.  
  2951. /*
  2952. -1 : error
  2953. 0 : directory is empty
  2954. 1 : empty directories inside
  2955. 2 : empty files inside
  2956. 3 : 1 + 2
  2957. 4 : not empty
  2958. */
  2959. int CheckDirInfo(CString path) {
  2960.   CWaitCursor wait;
  2961.   
  2962.   if (path.Right(1)!="\\")
  2963.     path+="\\";
  2964.   
  2965.   // Pour FindFirstFile/FindNextFile
  2966.   WIN32_FIND_DATA find;
  2967.   HANDLE h = FindFirstFile(path+"*.*",&find);
  2968.   
  2969.   // accessible
  2970.   if (h!=INVALID_HANDLE_VALUE) {
  2971.     int return_code=0;
  2972.     do {
  2973.       if (!(find.dwFileAttributes  & FILE_ATTRIBUTE_SYSTEM )) {
  2974.         if (strcmp(find.cFileName,"..")) {
  2975.           if (strcmp(find.cFileName,".")) {
  2976.             if (find.dwFileAttributes  & FILE_ATTRIBUTE_DIRECTORY ) {
  2977.               return_code|=1;
  2978.               int r=CheckDirInfo(path+find.cFileName);
  2979.               if (r==4)
  2980.                 return_code=4;
  2981.               else
  2982.                 return_code|=r;
  2983.             } else {
  2984.               return_code|=2;
  2985.               if ((find.nFileSizeLow) || (find.nFileSizeHigh))
  2986.                 return_code=4;
  2987.             }
  2988.           }
  2989.         }
  2990.       }
  2991.     } while(FindNextFile(h,&find) && !((return_code & 4)) );
  2992.     FindClose(h);
  2993.     return return_code;
  2994.   } else
  2995.     return -1;
  2996. }
  2997.  
  2998. /*
  2999. Remove Empty Dir
  3000. */
  3001. BOOL RemoveEmptyDir(CString path) {
  3002.   CWaitCursor wait;
  3003.   
  3004.   SetCurrentDirectory("C:\\");
  3005.   
  3006.   if (path.Right(1)!="\\")
  3007.     path+="\\";
  3008.   
  3009.   // Pour FindFirstFile/FindNextFile
  3010.   WIN32_FIND_DATA find;
  3011.   HANDLE h = FindFirstFile(path+"*.*",&find);
  3012.   
  3013.   // accessible
  3014.   if (h!=INVALID_HANDLE_VALUE) {
  3015.     do {
  3016.       if (!(find.dwFileAttributes  & FILE_ATTRIBUTE_SYSTEM )) {
  3017.         if (strcmp(find.cFileName,"..")) {
  3018.           if (strcmp(find.cFileName,".")) {
  3019.             if (find.dwFileAttributes  & FILE_ATTRIBUTE_DIRECTORY ) {
  3020.               if (!RemoveEmptyDir(path+find.cFileName)) {
  3021.                 FindClose(h);
  3022.                 return 0;
  3023.               }
  3024.             } else {
  3025.               if ((!find.nFileSizeLow) && (!find.nFileSizeHigh))
  3026.                 if (!DeleteFile(path+find.cFileName)) {
  3027.                   FindClose(h);
  3028.                   return 0;
  3029.                 }
  3030.             }
  3031.           }
  3032.         }
  3033.       }
  3034.     } while(FindNextFile(h,&find));
  3035.     FindClose(h);
  3036.     
  3037.     SetCurrentDirectory("C:\\");
  3038.     return RemoveDirectory(path.Left(path.GetLength()-1));
  3039.   } else
  3040.     return 0;
  3041.   return TRUE;
  3042. }
  3043.